passport-tutorial
passport-tutorial copied to clipboard
res.status is not a function
i am getting this issue
Error handling use
middleware must be 4 parameter not 3. Actually res.status
becoming as next.status
so next
has no status
function
The default error handler chapter: https://expressjs.com/en/guide/error-handling.html
app.use((err, req, res) => {
Change to :
app.use((err, req, res, next) {
Try this code if it works
app.use(function (err, req, res, next) { res.status(err.status || 500);
res.json({
errors: {
message: err.message,
error: err,
},
});
}) }
app.use(function(err, req, res, next) { res.status(err.status || 500);
res.json({ errors: { message: err.message, error: {}, }, }); });
Hi, Solved that issue. by adding extra params
On Thu, Oct 4, 2018 at 1:56 AM Jeremy Bacca Barquero < [email protected]> wrote:
Try this code if it works
app.use(function (err, req, res, next) { res.status(err.status || 500);
res.json({ errors: { message: err.message, error: err, }, });
}) }
app.use(function(err, req, res, next) { res.status(err.status || 500);
res.json({ errors: { message: err.message, error: {}, }, }); });
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/AntonioErdeljac/passport-tutorial/issues/1#issuecomment-426788840, or mute the thread https://github.com/notifications/unsubscribe-auth/AdOtOJCm6fuwAdnwZ6eNMP5ti-FMdodXks5uhR1fgaJpZM4VgAQ- .
hey @DarveshHere I'm having this error :
{ "errors": { "message": "Cannot read property 'email' of undefined", "error": {} } }
when trying to POST a user , could you help me please?
regards
Hi Darvesh, Kindly send this payload from the front end or postman . { email: "[email protected]", password:"xxxx"}
Note:- POST request with body containing keys email and password.
On Wed, Oct 31, 2018 at 8:48 PM llermaly [email protected] wrote:
hey @DarveshHere https://github.com/DarveshHere I'm having this error :
{ "errors": { "message": "Cannot read property 'email' of undefined", "error": {} } }
when trying to POST a user , could you help me please?
regards
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/AntonioErdeljac/passport-tutorial/issues/1#issuecomment-434725979, or mute the thread https://github.com/notifications/unsubscribe-auth/AdOtOF9L7pVLZ3witeIbNZQxxoacTY9Sks5uqb84gaJpZM4VgAQ- .
i get a POST /users 404 0.404 ms - 145 can someone help me ? it appears after i changed the extra next argument
please fix this code correct i want to learn from this code :)
Make sure your POSTMAN GET request has Headers; Key:Token
I am getting the same error: res.status is not a function and have changed the code as suggested:
app.use(function(err, req, res, next) {
res.status(err.status || 500);
res.json({
errors: {
message: err.message,
error: err,
},
});
});
}
but continue to get the same error. Is there a working example of this code anywhere? Would love to continue learning passport, et.al.
Regards,
Daryl
replace line ** return status(400).info**
with
return res.status(400).send(info);
I too am experiencing a problems related to this bug and the suggested fixes are not quite working for me.
On, lines 41 & 53 in app.js, I have:
app.use((err, req, res, next)
and on line 67 in users.js, I have:
return res.status(400).send( info );
however, when I start and visit http://localhost:8000/, I get the message in the browser:
Cannot GET /
I am getting the same problem as @williehallock802
I have the same error as above ^