Backend API Setup
Steps
In the
demos
directory, installjson-server
cd demos //if you aren't there already
npm install json-serverCreate directory
api
at the top level in your projectCreate the file
api\db.json
Copy the data from here into the file.
Open
package.json
Add the following script:
"scripts": {
"start": "serve -s",
+ "api": "json-server ./api/db.json"
},
Run the server
npm run api
You should see the following result:
\{^_^}/ hi!
Loading ./api/db.json
Done
Resources
http://localhost:3000/posts
http://localhost:3000/comments
http://localhost:3000/albums
http://localhost:3000/photos
http://localhost:3000/users
http://localhost:3000/todos
Home
http://localhost:3000