Reputation: 11
I initially created my e-commerce project with React. Later I realized I need mongodb and node for it. How can I integrate my React app to Node Js so it becomes a full stack app?
I want them to be in one folder.
Upvotes: 1
Views: 102
Reputation: 62
Nodejs is your backend from where you just connect to MongoDB and then return the data to your frontend, and to do that you will need to create API's on the backend and call them from your frontend.
And to do that you can initialize your nodejs in the same folder as react but I would recommend having two folders like backend and the frontend. Start your node app on some port, connect the MongoDB (use env variables), and create routes that the front end would call to get the information or post some information to the database.
To Sum up:
That's it, hopefully, it helps.
Upvotes: 1