supriya hj
supriya hj

Reputation: 1

How to display the json data in drupal 8 page?

How to display the json data in drupal 8 page?

Hi Team, I am looking out for possible solutions to display the data from external API in a drupal page.

  1. calling the API on page load.
  2. API call results a json array
  3. need to pick the data from the result and display in the following format in drupal 8 page.enter image description here

Please suggest the best approach for this requirement. Note: we are not supposed to store the fetch data in drupal db. we need to use drupal page to display the content alone.

Upvotes: 0

Views: 699

Answers (1)

MacSim
MacSim

Reputation: 384

You'll need to build a custom module to:

  1. Add a service which will fetch the data from your API call using \GuzzleHttp\Client::request()
  2. Create a custom route which will use the service and return a renderable array of data
  3. Create a template which will be used by your custom route to format the data as you want it to be displayed

Upvotes: 0

Related Questions