**Hello guys. A little help locating the root cause of this http 400 Error please. Setup is REST API NodeJs +Mysql . So here is a summary of where I am at:
- User successfully signed up
- JWT tokens successfully generated for user
- Model done, POST, GET, DELETE etc works fine.
- If I add JWT Token to JSON input and extract from code, it works fine.
- When I attempt to retrieve it from the Headers.authorization, then it fails.
See key code sections below :
Module.exports = (req, res, next){ const token = req.Headers.Authorization.split(" ")[1]; //const token2 = req.body.token; /*this worked!*/ const decoded = jwt.verify(token, process.env.SECRET); req.udata = decoded; }
**
JSON Object input as follows:
{
"project_Id" : 2,
"lots" : [
{
"sn" : "1",
"lotname" : "Consultancy Project NASA",
"value" : "N10m",
"status" : "awarded"
},
{
"sn" : "1",
"lotname" : "Consultancy Project NASA",
"value" : "N10m",
"status" : "awarded"
}
],
"applicant_Id" : 4,
"pitch" : "I am the best, you are will be sorry if you do not take me"
}
And finally, the Postman screen that has tormented me all night