I have created a project in WebStorm by watching a tutorial Node.js + Express - Tutorial - Insert and Get Data with MongoDB (check from 1:49 to 1:53 (I get error when I run www.js))
when i run localhost:8000, im able to insert the data,but i am not able to get the data,i get the below error
GET / 200 44.467 ms - 1968 GET /stylesheets/style.css 200 27.109 ms - 962 GET /favicon.ico 404 6.245 ms - 199 POST /insert 302 245.066 ms - 46 GET / 304 5.643 ms - - GET /stylesheets/style.css 304 1.362 ms - - C:\Users\ptech-user\WebstormProjects\aishuuu\node_modules\mongodb\lib\mongo_client.js:421 throw err ^
AssertionError [ERR_ASSERTION]: null == 'MongoError: failed to connect to server [localhost:27017] on first connect [MongoError: connect ECONNREFUSED 127.0.0.1:27017]' at C:\Users\ptech-user\WebstormProjects\aishuuu\routes\index.js:37:12 at connectCallback (C:\Users\ptech-user\WebstormProjects\aishuuu\node_modules\mongodb\lib\mongo_client.js:515:5) at C:\Users\ptech-user\WebstormProjects\aishuuu\node_modules\mongodb\lib\mongo_client.js:418:11 at _combinedTickCallback (internal/process/next_tick.js:131:7) at process._tickCallback (internal/process/next_tick.js:180:9)
How to solve this?
You do not have and 'http://' module instead of this you have 'http'. Edit the require statement in the following way
Incorrect
Correct
For a better understanding of what you do take a more in-depth tutorial about Node.Js and how it works. Resource: https://www.guru99.com/node-js-tutorial.html