Open ladyleet1337 opened 3 years ago
I had the same error! Express v14.17.3
I edit this lines in server.js: // parse requests of content-type - application/json app.use(express.json()); // parse requests of content-type - application/x-www-form-urlencoded app.use(express.urlencoded({ extended: true }));
And I realised that Postman is not sending the POST request as expected, I used advancedrestclient instead with no problems.
Make sure to delete bodyParser below. app.use(bodyParser.json()); app.use(bodyParser.urlencoded({ extended: true }));
Replace it with the new native express integration. app.use(express.json()); app.use(express.urlencoded({extended: true}));
When you send the request to the API, use JSON format. I recommend to use "Insomnia" to test.
Make sure to delete bodyParser below. app.use(bodyParser.json()); app.use(bodyParser.urlencoded({ extended: true }));
Replace it with the new native express integration. app.use(express.json()); app.use(express.urlencoded({extended: true}));
When you send the request to the API, use JSON format. I recommend to use "Insomnia" to test.
No that didn't worked. Still getting the same error.
Make sure to delete bodyParser below. app.use(bodyParser.json()); app.use(bodyParser.urlencoded({ extended: true }));
Replace it with the new native express integration. app.use(express.json()); app.use(express.urlencoded({extended: true}));
When you send the request to the API, use JSON format. I recommend to use "Insomnia" to test.
Not worked
I had the same error! Express v14.17.3
I edit this lines in server.js: // parse requests of content-type - application/json app.use(express.json()); // parse requests of content-type - application/x-www-form-urlencoded app.use(express.urlencoded({ extended: true }));
And I realised that Postman is not sending the POST request as expected, I used advancedrestclient instead with no problems.
Did the changes but they didn't worked
I have given the below things in the body
{ "username": "modera", "email": "abc@xyz.com", "password": "12345678", "roles": ["user", "moderator"] }
Below is the exception error i am getting
Error: Illegal arguments: undefined, string at Object.bcrypt.hashSync (/home/labadmin/lab/node-js-jwt-auth-mongodb-master/node_modules/bcryptjs/dist/bcrypt.js:189:19) at exports.signup (/home/labadmin/lab/node-js-jwt-auth-mongodb-master/app/controllers/auth.controller.js:13:22) at Layer.handle [as handle_request] (/home/labadmin/lab/node-js-jwt-auth-mongodb-master/node_modules/express/lib/router/layer.js:95:5) at next (/home/labadmin/lab/node-js-jwt-auth-mongodb-master/node_modules/express/lib/router/route.js:137:13) at checkRolesExisted (/home/labadmin/lab/node-js-jwt-auth-mongodb-master/app/middlewares/verifySignUp.js:51:3) at Layer.handle [as handle_request] (/home/labadmin/lab/node-js-jwt-auth-mongodb-master/node_modules/express/lib/router/layer.js:95:5) at next (/home/labadmin/lab/node-js-jwt-auth-mongodb-master/node_modules/express/lib/router/route.js:137:13) at User.findOne.exec (/home/labadmin/lab/node-js-jwt-auth-mongodb-master/app/middlewares/verifySignUp.js:34:7) at immediate (/home/labadmin/lab/node-js-jwt-auth-mongodb-master/node_modules/mongoose/lib/model.js:5065:18) at process._tickCallback (internal/process/next_tick.js:61:11)