4 - Add JSON server

1. npm install json-server and ts-node

  • add json-server and ts-node

npm i json-server ts-node --save-dev
  • Add a folder called server to the root directory and paste in the below code

2. Make a server.ts file in a new folder called server

  • Make a new folder called server

Server folder on root of project
  • Make file called server.ts in the new server folder and paste in the below code. You do not need to study or learn this min node express app it is just to have a mock backend.

3. Add a file called db.json

  • Make file called db.json for mock data in the new server folder

4. Add the below script to the scripts in the package.json

5. Start the server and leave it running

  • Start the server and leave it running whenever you use the apps. It is easier to run in a seperate terminal to VS Code so when you refresh the IDE you do not kill this server.

6. Navigate to http://localhost:3000

  • Check it is working.

8. Commit your code

Last updated