create-contentful-app icon indicating copy to clipboard operation
create-contentful-app copied to clipboard

how to get linked to entry data?

Open phpstudyone opened this issue 1 year ago • 2 comments

I expect to retrieve all data linked to this entry. I used the following code:

const sdk = useSDK();
const entryId = sdk.entry.getSys().id;

sdk.cma.entry.references({ entryId: entryId, include: 10 }).then(a=>{
    console.log(a, 3343434)
})

But it seems that the returned data is the entry itself, rather than the data that references this entry. What did I miss?

image

phpstudyone avatar Aug 31 '23 10:08 phpstudyone

To get the data linked to the entry, it seems that you can only call preview-contentful-api. But the cma in useSDK uses the manage-contentful api. How do I use useSDK to get this content?

phpstudyone avatar Sep 05 '23 08:09 phpstudyone

I'm just getting my head around contentful apps myself. I think you're using the wrong function call. I don't know which one you should use though.

For anyone landing on this thread, sdk.cma.entry.references({ entryId: entryId, include: 10 }) retrieves the entry, plus data for the reference fields in that entry. For reference fields sdk.cma.entry only includes the field sys data, not the actual referenced entry.

eloisetaylor5693 avatar Jul 12 '24 08:07 eloisetaylor5693