How to Save Data to MongoDB with Node.js for Beginners | EP.5 Build an API with Node.js and Express

  Рет қаралды 4,282

Devtamin

Devtamin

Жыл бұрын

In this tutorial, I will show you how to save data to database like MongoDB in Node.js. I will teach you step-by-step so it will be easy for you to follow along. I will use Insomnia to send a post request to Node.js. Then, the data from the request will be save to MongoDB by using Model.
This video is in the playlist of building an API with Node.js and Express. Look no further! In this playlist, I will teach you how to build an API quickly and easily.
Source Code - github.com/devtamin/Node-API

Пікірлер: 6
@oakz1975
@oakz1975 3 ай бұрын
i used the sample from the github and get this error: Operation `products.insertOne()` buffering timed out after 10000ms
@rvlogs4717
@rvlogs4717 Жыл бұрын
I am getting “cannot access ‘product’ before initiallization” error how can solve this..
@Devtamin
@Devtamin Жыл бұрын
Sorry about that. Check the source code on GitHub, github.com/devtamin/Node-API
@TJPBataller
@TJPBataller Жыл бұрын
I'm lost, when did we created the products folder under Node-API? Please help.
@user-jl5cc7vk9h
@user-jl5cc7vk9h 10 ай бұрын
automatically Product model name is replaced as the products in the Node-API. collection name is allways in the lowercase and plural form if you not do this the this done by mongoDB itself.
@thuannguyenlehoa9711
@thuannguyenlehoa9711 Жыл бұрын
const userController = { registerUser: async (req, res, next) => { try { const newUser = await User.create(req.body); res.status(200).json(newUser); } catch (error) { res.status(500).json("Tao tài khoản k thành công"); } }, }; The code always run catch(). But when i just use const newUser = await User(req.body), it's ok. Please help me!
Heartwarming Unity at School Event #shorts
00:19
Fabiosa Stories
Рет қаралды 23 МЛН
Я обещал подарить ему самокат!
01:00
Vlad Samokatchik
Рет қаралды 7 МЛН
Intro to MongoDB and Mongoose | Node.js Tutorials for Beginners
17:06
How to send your data to mongoDB | Backend tutorial | MongoDB Compass
10:20
Connecting NodeJS with MongoDB | Mongoose + Express
19:18
Piyush Garg
Рет қаралды 100 М.
Passing Data Between Frontend and Backend | Node.js
18:31
Smoljames
Рет қаралды 85 М.
Protocol Buffers Crash Course
36:07
Hussein Nasser
Рет қаралды 240 М.
Node.js Crash Course Tutorial #9 - MongoDB
35:56
Net Ninja
Рет қаралды 432 М.
Build a Rest Api with NodeJS (JavaScript), Express, and PostgreSQL
1:07:53
I tried 8 different Postgres ORMs
9:46
Beyond Fireship
Рет қаралды 397 М.
Build A REST API With Node.js, Express, & MongoDB - Quick
28:56
Web Dev Simplified
Рет қаралды 809 М.