-
Notifications
You must be signed in to change notification settings - Fork 0
/
Index.js
45 lines (26 loc) · 871 Bytes
/
Index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
const express = require ('express');
const mongoose = require ('mongoose');
const cors = require ('cors');
require('dotenv').config();
const Orders = require ('./modals/Form.modal');
const app = express();
const URL = process.env.ATLAS_URL;
app.use(cors())
app.use(express.json())
mongoose.set('strictQuery', false);
mongoose.connect(URL, {
useNewUrlParser: true,
useUnifiedTopology: true,
});
const connection = mongoose.connection;
connection.once('open',() => {
console.log('mongoose db connected successfully...!!!')
})
app.post('/Orders',async(req,res) =>{
const {UserName,phoneNumber,email,address,LandMark,PinCode} = req.body;
const newOrders = new Orders({UserName,phoneNumber,email,address,LandMark,PinCode});
await newOrders.save();
})
app.listen("8001", () => {
console.log("Server is running on port 8001");
});