How to create mock API for JSON data - DevOli/Marvel-chars GitHub Wiki
For implement the API, we use the platform “mockapi.io” to upload the JSON file example.
- First we need to create an account on the platform, or login with GitHub or Gmail:
- We need to create a New Project tapping the “Add Icon”
- For the basic setup, we set a Project Name and API Prefix
- At this point we define to use only a general endpoint, so it was necessary to create only one resource. The JSON example is just an Object, so we create a new resource of type Object and ID for default:
- With the new resource, we define the amount of Objects below the name with a slider, on this case just one, and edit the content tapping on Data button.
- Paste the JSON file example
- At this point we’ve got the API ready to use and test with postman, using the url and the name of the resource (endpoint):
URL: "https://619d463f131c600017088e71.mockapi.io/api/v1/characters"
- Last step, test the endpoint using Postman: