Skip to content

Latest commit

 

History

History
61 lines (38 loc) · 691 Bytes

start.md

File metadata and controls

61 lines (38 loc) · 691 Bytes

Sample Nodejs restful API

initial environment

Verify if nodejs installed on the local environment or not:

node -v npm -v

If not, install it first

  1. Getting to the node API folder and initial npm:
cd nodeapp

npm init
  1. Install express & nodemon
npm i express

npm i -g nodemon

  1. Open the package.json file and add this task to the script
"start": "nodemon server.js"

  1. start server:
npm run start

Nodejs API server start on 8080

verify from postman

Get books:

URL:   http://localhost:8080/api/books/
Method: GET

Add book:

URL:   http://localhost:8080/api/books/
Method: GET
request body:
{"name":"mybook"}