Hi all, I’m having trouble finding documentation describing a successful API response from updating an entry - specifically entries with images.
I have fairly simple content model for project
entries. One of the fields on that content type is an image, previewImage
.
After an initial getEntry(id)
call, the previewImage
object returned in the response looks like this:
{
"sys": {
"space": {
"sys": {
"type": "Link",
"linkType": "Space",
"id": "..."
}
},
"id": "...",
"type": "Asset",
"createdAt": "2019-09-04T02:50:46.358Z",
"updatedAt": "2019-09-04T02:50:46.358Z",
"environment": {
"sys": {
"id": "master",
"type": "Link",
"linkType": "Environment"
}
},
"revision": 1,
"locale": "en-US"
},
"fields": {
"title": "HolidayPromo2",
"file": {
"url": "//images.ctfassets.net/33v24meurdnv/6wQkd3u7BAbgsuWkpHurYI/5d130e3206481011808f291727f649d5/somePicture.jpg",
"details": {
"size": 3917322,
"image": {
"width": 1640,
"height": 7814
}
},
"fileName": "somePicture.jpg",
"contentType": "image/jpeg"
}
}
}
The above works great in my application since the file URL is in the response.
However, after updating a different field in the same entry, I receive a different response format for the previewImage
object:
{
"en-US": {
"sys": {
"type": "Link",
"linkType": "Asset",
"id": "6wQkd3u7BAbgsuWkp..."
}
}
}
I was hoping to get a the previewImage
's file URL back after the update, but this response doesn’t include it.
Is there a way to get the a response similar to the original getEntry()
call after I’ve updated the entry?
It could be that I’ve updated, and published the entry incorrectly, the code for that is below:
export async function projectLike(entryId) {
const space = await client.getSpace(process.env.REACT_APP_SPACE_ID);
const entry = await space.getEntry(entryId);
entry.fields.likes["en-US"] = entry.fields.likes["en-US"] + 1;
const updatedEntry = await entry.update();
const publishedEntry = await updatedEntry.publish();
const publishedEntryResponse = await space.getEntry(publishedEntry.sys.id);
return publishedEntryResponse;
}
If there’s documentation on how the API returns successful responses to updated on entries with assets and I’ve missed it, my bad.
Would appreciate any guidance!