-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
Learn React Hooks - Second Edition
By :
Before we can implement requests, we need to implement a server. Since we are focusing on the user interface in this book, we are going to set up a dummy server, which will allow us to test out requests. We are going to use the json-server tool to create a mock Representational State Transfer (REST) Application Programming Interface (API) from a JSON file.
To be able to use the json-server tool, we first need to create a db.json file, which is going to contain the database for the server. The json-server tool will then create a REST API that allows us to access and modify the db.json file, as follows:
GET requests, to view data from the filePOST requests, to insert new data into the filePUT and PATCH requests, to adjust existing data in the fileDELETE requests, to remove data from the fileThe structure of the REST API is inferred from a JSON object in the db.json file. For...