1

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.

  • Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. – Community Nov 19 '22 at 12:07

1 Answers1

1

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:

  • Set up node js
  • create a mongodb cluster
  • connect the cluster to node
  • create APIS in node (get, post etc. requests)
  • call the backend API in front end (react) to access/manipulate the database information

That's it, hopefully, it helps.