Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialMasha Blair
13,005 PointsIn REST-API w/ Express class, I can't create a new quote by sending a POST request to my local server w/ Postman.
In REST-API w/ Express class, I can't create a new quote by sending a POST request to my local server w/ Postman.
Everything seems to be exactly the same as teachers code and actions -- my local server is running, the code is the same, but when I hit 'Send' in Postman with a new quote JSON, my status code is 404 Not Found. So no new record is created in data.json
Can someone please help?
2 Answers
Muhammad Anwar Ul Haq
Full Stack JavaScript Techdegree Graduate 18,781 PointsHere is the code
app.post("/quotes", async (req, res) => {
const quote = await records.createQuote({
quote: req.body.quote,
author: req.body.author,
});
res.json(quote);
});
Masha Blair
13,005 PointsNever mind, when I tried 'Send' again in 5 minutes, it worked and I got 200 OK status. Weird!
Chai Chong Teh
25,709 PointsI initially stumbled upon the same thing, then I found out that it was because of the typo at Postman.