Hi I have added custom field in post entries that will record the IDs of the uploaded media.
from the JSON it is know that the list of media is stored in
wp-json/wp/v2/media?parent=[postID]
How should I fetch the media by ID, or convert to a proper fetch URL?
after that, should retrieve them with state.source.attachment[id]?
or any other more preferred methods?
thanks!
Hello everyone, I am having this same issue. I fetch all data for my categories using the beforeSSR hook and I get access to all the information but the media link. And the media link (featured image) is not on the state.
I am back answering my own question. What I finally did was to add the featured image source in the rest object by using the register_rest_field WordPress function.