我有一个内容堆栈 API 调用,如下所示:
const Entry = Stack.ContentType('home').Entry("blt5e6d02158a314e4c");
Entry.fetch()
.then(function success(entry) {
console.log(entry.toJSON());
})
返回这样的响应:
{
"_version":13,
"locale":"en-us",
"uid":"blt5e6d02158a314e4c",
"modular_blocks":[
{
"banner":{
"title":"Test banner title",
"background_image":null
}
},
{
"listing":{
"title":"Test listing",
"food_items":[
{
"uid":"blt3dc93d9d43186dd3",
"_content_type_uid":"food_item"
},
{
"uid":"blt9b3e1baeb2e3fe17",
"_content_type_uid":"food_item"
},
{
"uid":"bltf74ee44deee6501b",
"_content_type_uid":"food_item"
},
{
"uid":"blt3a164e1dcdf7fd8b",
"_content_type_uid":"food_item"
},
{
"uid":"blt9093f3bb9135e7b1",
"_content_type_uid":"food_item"
},
{
"uid":"blta1e533c66e8cf57a",
"_content_type_uid":"food_item"
},
{
"uid":"blt67728d24e4e704f2",
"_content_type_uid":"food_item"
},
{
"uid":"blt5af3ad110269ac72",
"_content_type_uid":"food_item"
},
{
"uid":"blt7a263ba68a1a39eb",
"_content_type_uid":"food_item"
},
{
"uid":"blt85cef2ca76051a6e",
"_content_type_uid":"food_item"
},
{
"uid":"blt857356711e1637a6",
"_content_type_uid":"food_item"
},
{
"uid":"blt446e027c9e069362",
"_content_type_uid":"food_item"
}
]
}
}
]
}
如何在此回复中包含“food_item”内容条目的详细信息?我真的需要单独查询其中每一个才能获取这些详细信息吗?
我发现了这一点,你必须在 Entry 上使用 .includeReference 方法,如下所示 ->
Entry
.includeReference(['modular_blocks.listing.food_items'])
.fetch()