Node MongoDB REST API using Express framework. How to build blog app using Node.js RESTful API. Node.js MongoDB login, register, CRUD, query, and more.
Last Part (Designing Blog Website): https://youtu.be/tlTdbc5byAs
Next Part (MERN Stack Blog App): https://youtu.be/LelifxOrzvw
Buy me a coffee: https://www.buymeacoffee.com/lamadev
Source Code: https://github.com/safak/youtube/tree/blog-rest-api
Join Lama Dev groups
Facebook: https://www.facebook.com/groups/lamadev
Instagram: https://www.instagram.com/lamawebdev
Twitter: https://twitter.com/lamawebdev
Discord: https://discord.gg/yKremu4mPr
0:00 Introduction
1:15 Installation
3:46 How to Create an Express Server?
8:05 Node.js MongoDB Connection
11:03 Node.js MongoDB Creating Models
17:31 Node.js MongoDB Login and Register Routes
35:09 Node.js MongoDB User CRUD
49:17 Node.js Post CRUD
59:15 Node.js Request Query
01:04:55 GET and POST Category
01:08:35 Node.js Upload File REST API
01:14:45 Outro
dear sir your backend api is tomuch difficult.. i make new api update and delete… and working…plz make samll and short code…. check my api code
//delete api code and working
router.delete("/:id", async (req, res) => {
const result = await Post.deleteOne({_id: req.params.id});
res.send(result);
});
//update Api working in your project…
router.put("/:id", async (req,res) =>{
const result = await Post.updateOne(
{_id: req.params.id},
{$set: req.body}
)
res.send(result)
})
35:09
So if i want to add Google authentication to this how can i do it? tips would be helpful
Very nice way of explaining. Would had been the perfect node tutorial if it had the comments feature as well. Nonetheless keep up the good work sir. Love from Pakistan.
I thankyou so much sir, for your effort I learnt a lot from your videos. Please continue this type of videos. These are really helpful.
How to solve bad authentification ini mongodb
dude you are the best
Thank you🥰🥰🥰🥰
My postman send 200 with the perfect response but on mongoDB there is no data?? please help me out with this
did anyone else have problems with the delete operation on the user route?
its saying that new posts is not a constructor
Thanks so much for this great tutorial.
thankyou!
10:00 The useCreateIndex option has been deprecated for a while and removed as of the Mongoose 6 release per No More Deprecation Warning Options:
useNewUrlParser , useUnifiedTopology , useFindAndModify , and useCreateIndex are no longer supported options. Mongoose 6 always behaves as if useNewUrlParser , useUnifiedTopology , and useCreateIndex are true , and useFindAndModify is false .
My password validated doesn't want to work, Error message: Cannot set headers after they are sent to the client.
Does anyone know the solution?
Thanks for this great tutorial 🤩
thx! hari om! lama
Love these. You are like the Bob Ross of code tutorials.
{
"errors": {
"username": {
"name": "ValidatorError",
"message": "Path `username` is required.",
"properties": {
"message": "Path `username` is required.",
"type": "required",
"path": "username"
},
"kind": "required",
"path": "username"
},
"email": {
"name": "ValidatorError",
"message": "Path `email` is required.",
"properties": {
"message": "Path `email` is required.",
"type": "required",
"path": "email"
},
"kind": "required",
"path": "email"
},
"password": {
"name": "ValidatorError",
"message": "Path `password` is required.",
"properties": {
"message": "Path `password` is required.",
"type": "required",
"path": "password"
},
"kind": "required",
"path": "password"
}
},
"_message": "Users validation failed",
"name": "ValidationError",
"message": "Users validation failed: username: Path `username` is required., email: Path `email` is required., password: Path `password` is required."
}
i got the error in 26:27
Pls can someone help? My server crashes when I make a login request with a wrong username
MulterError: Field name missing kindly help me to solve this error
That's a really nice work !! Thank you very much it s a good project ^^ I enjoy your projects , it s the best way to practice and learn 😉
Login is not working.
MongooseServerSelectionError i keep getting this error when i use the college wifi . I want to know how to resolve this issue
not connection mongoose.connect(process.env.MONGO_URL, {
useNewUrlParser: true,
useUnifiedTopology: true,
useCreateIndex: true,
});
Anybody else have trouble querying by category after adding categories to each post?
where is your previous lesson
moving everything to client messed up everything
How to link category with posts
I wrote the exact code that you wrote but when I was testing the register api it was showing error even after using express.json(). Can anyone give me any solution. I was using thunder client for the testing.
am facing a lot of problems i.e. errors while making this…
hey !! can you make a video on how to make this applications for production environment … and what is the pro way of making the same website
i don't know why your voice your explain style made me addicted to you. I don't understand other channels…
57:13 If anyone struggling with code try this delete should be change as a deleteOne !
If you are beginner… Start with this vedio… Awsm
Yeah, finally complete this part. Thanks a lot, Lama 先生(sensei). Some parts were a bit difficult and as of April 2023, some parts of the code didn't work properly. So if anyone gets stuck, can see the other comments for solving. Hope can complete the last part of the series properly.
hey lama when i test on postman the delete request on post it send an internal server error while everything is good
Thank you for linking your github source code. It helps so much.
ye bhau hindi madhe bol na
😍🥰❤💫
i am not able to delete the posts and get posts, no luck finding solutions on web too
53:00
Hello Lama Dev, I have been following through your tutorial and I must acknowledge that your method of instructing is topnotch. Thank you so much for the outstanding content you are giving out.
Around 34:00:00 I faced errors while trying wrong credentials multiple times in a row.
"Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client".
I had to change the login route code to this, notice the use of return:
router.post('/login', async (req, res) => {
try {
const user = await User.findOne({ username: req.body.username });
if (!user) {
res.status(400).json('Wrong credentials!');
return;
}
const validated = await bcrypt.compare(req.body.password, user.password);
if (!validated) {
res.status(400).json('Wrong credentials!');
return;
}
const { password, …others } = user._doc;
res.status(200).json(others);
} catch (err) {
res.status(500).json(err);
}
});
Hope this helps someone else 🚀
at 44:38 what should the if statement look like for the user?
Did anyone got the Solution ? of why we are getting stucked on 26:27 , after sending request to postman, there is no response by the postman, and after some time it shoes the response timeout error , if anybody can help, I have gone through the code, few times by know and i guess it seems perfect as there is no error in my VS code console too , but the postman is not responsing, if anyone can help ..thanks
For deleting posts
await post.delete() was giving error 500
It resolved by using deleteOne() instead of delete
resume 17:43
57:16 I can created a post, can updated the post, but can't delete post, 100% follow the code already. the error is 500, and the postman result is nothing -> { }