- Trying out building api calls
- Trying out mongo db with reference to their original website
- Reference : https://codeforgeek.com/2015/08/restful-api-node-mongodb/ (Implementation based on the blog)
Sample request for post:
Installation Steps:
-
npm install
-
create data directory mkdir data
-
start mongodb server and mention the dbpath as data
mongod --dbpath=data
-
npm start
API Calls:
- localhost:3000/notes -- GET/POST
PAYLOAD { "title" : "Javascript", "fieldID" : "1234", "content": "Callback functions", "status" : true, "targetDate": "2017-01-06T17:32:38.292Z" }
- localhost:3000/notes:id
To get the existing userid login to mongoshell in a new terminal
- mongo
- use myProject
- show tables
- db.notedetails.find()
select one of the ids from the document and add in the api call (POST atleast one entry from api call /users before selecting)