An open API service indexing awesome lists of open source software.

https://github.com/themiu/mongo-crud

Simple CRUD operations test with MongoDB, using React Frontend and Express Backend
https://github.com/themiu/mongo-crud

axios-react express-js mongodb mongodb-atlas mongoose

Last synced: 3 months ago
JSON representation

Simple CRUD operations test with MongoDB, using React Frontend and Express Backend

Awesome Lists containing this project

README

          

## MongoDB CRUD Operations with React

Simple CRUD operations test with MongoDB, using React Frontend and Express Backend

## Setup MongoDB

### Backend

* `npx express-generator`
* `npm install`
* `npm install nodemon`
* `"dev":"nodemon ./bin/www"` add to scripts


* `npm install dotenv`
* create .env (my .env file is added to gitignore, so create a new .env file in backend with your MONGODB_URL)

`PORT=4000
MONGODB_URL=mongodb+srv://:@.auajvjv.mongodb.net/?retryWrites=true&w=majority`
* .env config


* `npm install mongoose`
* mongo db connect


* setup for perform CRUD operations (add customer)
* check using Postman

Post request URL : http://localhost:4000/customer/add

Sample data :


{
"id": "1",
"name": "John",
"address": "New York"
}

* Others requests are similar to that.
customer.js ,
CustomerController.js

### Access Backend from Frontend

* create React app + tailwind css
* `npm install cors` (backend)
* Enable CORS (backend)
* `npm install axios` (frontend)
* Create frontend to manipulate the data.