@thefourtheeye Regarding the answer you provided above, where in my directory/file should I put the "var express" and or the "var bodyParser" code?
I am following this guide (http://nodeexamples.com/2012/09/21/connecting-to-a-postgresql-database-from-node-js-using-the-pg-module/) regarding Postgres and Node.js database and I got to the very end to the part where it says to call the command
node app.js
or in my case
node web.js
however I get
Error: Most middleware (like logger) is no longer bundled with Express and must be
installed separately. Please see https://github.com/senchalabs/connect#middleware.
at Function.Object.defineProperty.get
I just want to test if my data was stored in the database as such
[
{
"firstname": "Mayor",
"lastname": "McCheese"
},
{
"firstname": "Ronald",
"lastname": "McDonald"
}
]
using the 'node name.js'How do I go about getting this specific command to work?
Edit: So I checked out morgan (https://github.com/expressjs/morgan) as @thefourtheye mentioned and I realize I need to add this code
var express = require('express')
var morgan = require('morgan')
var app = express()
app.use(morgan('combined'))
but I am not certain where in my code I need to add it. Also, as someone mentioned above in the redirect stovrflw question do I need to run
npm install body-parser
and then put this code in my project? If so what directory/file? Is it my main.js file?
var bodyParser = require('body-parser');
app.use(bodyParser.json());