In this blog post, I'm going to discuss how to configure JSON API in Drupal 8 and exposing node to JSON format.
We are going to create a gallery of heroes of Mobile Legends (mobile multiplayer online battle arena) and exposed it to JSON format.
Alright, Let's get started!
- Create a custom content type "Hero".
- Create a vocabulary class and add a new term.
- Add image, class field.
- Enable JSON:API and JSON API Extras module.
The JSON:API module provides zero-configuration out of the box. Use JSON:API Extras to customize your API. JSON:API Extras provides a means to override and provide limited configurations to the default zero-configuration implementation provided by the JSON:API module.
- Configure JSON:API Extras. Edit "Hero" resource and disable the fields that we don't need.
Only keep these fields.
- Create a "Hero".
- Visit the resource path /jsonapi/hero
In the second part of this blog post, I'm going to discuss how to display the data from Drupal 8 to Gatsby so stay-tuned.