How to store the json from external system | Community
Skip to main content
Ankur_Khare
Community Advisor
Community Advisor
March 9, 2020
Solved

How to store the json from external system

  • March 9, 2020
  • 2 replies
  • 3614 views

Hi Team,

 

We have a requirement where in we need to ca ll a 3rd party rest api to get a json response based on which we need to construct all the components on the page.

 

So my question is how shall we call the 3rd party api only once and then all the components use the same json response .

 

Please let us know the correct way of handling this scenario.

Note: we are not using SPA.

 

Regards

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by BrianKasingli

@64040 

When dealing with third-party APIs, the best practice is to always think of the best way to offload the server-load from your publishers. Ask questions like: does does this third-party API need to be a par of the HTML within the server-side render? If server-side render is not required, you can invoke the third-party API using Javascript, and with the response, using Javascript to render HTML elements to the page. This practice will keep your AEM publishers more performant and unblocked.

Read more here: https://sourcedcode.com/scenario-building-aem-components-with-3rd-party-integrations-the-right-way

In my experience, the best way to deliver a performant AEM website is to cache all pages. Try migrating all the content from the old CMS to AEM; in this case, you can utilise the Apache Sling Framework to do all the heavy lifting for you. Take a look at the custom data importer service, com.day.cq.polling.importer.Importer API.

 

2 replies

arunpatidar
Community Advisor
Community Advisor
March 9, 2020

You can make a request using HttpClient Api from sling servlet/services and store json inside /conf if not exposing to client, otherwise store inside content and use this json.

I would suggest parse/store this json as node, would be easy to access and use later.

Arun Patidar
Ankur_Khare
Community Advisor
Community Advisor
March 13, 2020
but the json value could be changed at any time so storing it in conf or content node needs to be scheduled rt..?
BrianKasingli
Community Advisor and Adobe Champion
BrianKasingliCommunity Advisor and Adobe ChampionAccepted solution
Community Advisor and Adobe Champion
March 9, 2020

@64040 

When dealing with third-party APIs, the best practice is to always think of the best way to offload the server-load from your publishers. Ask questions like: does does this third-party API need to be a par of the HTML within the server-side render? If server-side render is not required, you can invoke the third-party API using Javascript, and with the response, using Javascript to render HTML elements to the page. This practice will keep your AEM publishers more performant and unblocked.

Read more here: https://sourcedcode.com/scenario-building-aem-components-with-3rd-party-integrations-the-right-way

In my experience, the best way to deliver a performant AEM website is to cache all pages. Try migrating all the content from the old CMS to AEM; in this case, you can utilise the Apache Sling Framework to do all the heavy lifting for you. Take a look at the custom data importer service, com.day.cq.polling.importer.Importer API.