Kept trying to check POST on Postman… but I constantly get 400 Bad request.
My steps:
- Select POST, localhost:4001/api/quotes
- Body → Raw → json
- {“quote”: {“quote”:“bla”, “person”:“Anna”}}
What am I doing wrong? The code seems correct, it works in the browser.
I also tested POSTMAN, POST on the solution provided by Codecademy - but no success.
Do you have a link to the lesson you’re referring to?
Also, what items are checked under the “Headers” tab?
Thank you for replying.
Here link to the project:
https://www.codecademy.com/paths/back-end-engineer-career-path/tracks/wdcp-22-build-a-back-end-with-express-js/modules/wdcp-22-challenge-project-quote-api/projects/quote-api
Here post request:
app.post('/api/quotes', (req, res, next) => {
const quoteQuery = req.query.quote;
const personQuery = req.query.person;
if(quoteQuery !== undefined && personQuery !== undefined) {
const newQuoteObject = {
quote: quoteQuery,
person: personQuery
};
quotes.push(newQuoteObject);
res.send({quote: newQuoteObject});
} else {
res.status(400).send();
}
});
And attached headers