Setting up a simple backend server
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.
Creating the db.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:
GETrequests, to view data from the filePOSTrequests, to insert new data into the filePUTandPATCHrequests, to adjust existing data in the fileDELETErequests, to remove data from the file
The structure of the REST API is inferred from a JSON object in the db.json file. For...