Contentful logo

Contentful Community

Parsing returned JSON client side in JavaScript

Hi.

I am doing a call from my webapp to clientAPI.getEntries(), which returns the json of all of my entries. These include links to author/category/relatedArticles etc.

Is there a way for me to query this json object locally without further calls to the Contentful API. Is there a JavaScript library or API for doing this. e.g. for resolving the links for me to build up objects that I can display

Alternatively - if the ‘items’ array had all of the data instead of only having the ‘id’ to the include:[] array…?

Hi @briandev,

If you’re using the JavaScript SDK, it is indeed possible to resolve your links directly in your parent entries, by specifying a given resolveLinks parameter to true in your client setup, as explained in the following link:

Let me know if that helps or if you have other questions :slight_smile:

Thanks Gabriel. That pointed me in the right direction - and I figured out what I was doing wrong

I thought that the link resolution would take place on the Contentful Server side, so I was looking at the JSON that was being returned with the Http Response. I didn’t realise the contentful.js resolved the links and that the items[] would have the data already in a presentable form!! That’s great, thanks again

I’m glad this helped.
Let me know if you need help with anything else :slight_smile: