Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,194,849 members, 7,956,180 topics. Date: Monday, 23 September 2024 at 07:10 AM |
Nairaland Forum / Science/Technology / Programming / Someone Kind Enough Should Help Me With My Node.js Use.app() Path (574 Views)
Free PHP, Node js ,Mongo db, Angular And C# Proje Source Code With Documentation / React + Node Js : Fullstack Web Development Training / Please Help Me Test Out My Node JS Script (2) (3) (4)
Someone Kind Enough Should Help Me With My Node.js Use.app() Path by Princedapace(m): 5:09pm On Sep 07, 2021 |
So, I am trying to create a comment in my blog applictaion. I am using node.js. Here is my comment route path: router.post("/posts/:id/comment", async (req, res) =>{ const newComment = new Comment(req.body);//we create a new category for the database try{ const savedComment = await newComment.save();//we need to try and catch the new category and save it res.status(200).json(savedComment) }catch(err){ res.status(500).json(err) } }) The idea is to create comment inside a post. Here is the server path for the comment: app.use("/api/posts/", commentRoute) I think here is where I am missing it. Someone can direct me, pls. |
Re: Someone Kind Enough Should Help Me With My Node.js Use.app() Path by ClintonNzedimma(m): 6:26pm On Sep 07, 2021 |
Princedapace:Push to GitHub for a better explanation. I think I can help you 1 Like |
Re: Someone Kind Enough Should Help Me With My Node.js Use.app() Path by Heathen(m): 7:52pm On Sep 07, 2021 |
What's the actual problem? Your post doesn't state the actual problem |
Re: Someone Kind Enough Should Help Me With My Node.js Use.app() Path by spartan117(m): 7:20am On Sep 08, 2021 |
I'm guessing you exported the router from that file. If you did then the issue I can see here is that you repeated "posts" in both the router path and the app path. So your final path looks like this: /api/posts/posts/:id/comments. Posting the full code will help though because I'm not even sure if you are using express app and express router correctly. But this is all I can see that is wrong from what you posted. |
Re: Someone Kind Enough Should Help Me With My Node.js Use.app() Path by Princedapace(m): 6:38pm On Sep 08, 2021 |
spartan117:i have sorted out the problem. Thank you bro |
Re: Someone Kind Enough Should Help Me With My Node.js Use.app() Path by Princedapace(m): 6:59pm On Sep 08, 2021 |
ClintonNzedimma:I have sorted out the problem, bro. Thanks just have another problem with mongodb My postman is throwing this error when I want to add second comment. Thefirst comment goes on well. When I now want to add another, I get this error. { "driver": true, "name": "MongoError", "index": 0, "code": 11000, "keyPattern": { "title": 1 }, "keyValue": { "title": null } } |
(1) (Reply)
What Is The Next Course To Cover After This / Apple Iphone 6S Photos Have Been Leaked / Post All Your I.T.C Problems Here 4 Free(website&software Design,networking Etc)
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 15 |