File tree Expand file tree Collapse file tree 1 file changed +19
-18
lines changed Expand file tree Collapse file tree 1 file changed +19
-18
lines changed Original file line number Diff line number Diff line change @@ -14,22 +14,6 @@ var app = express();
14
14
15
15
app . use ( bodyParser . json ( ) ) ;
16
16
17
- // app.post('/api/activity', (req, res) => {
18
- //
19
- // //Create the actual activity model instance
20
- // var newactivity = new activitymodel({
21
- // text:req.body.text,
22
- // completed: req.body.completed
23
- // });
24
- //
25
- // //save the activity instance data to the document-tblactivities
26
- // newactivity.save().then((doc) => {
27
- // res.status(201).send(doc);
28
- // }, (err) => {
29
- // res.status(400).send(err);
30
- // });
31
- //});
32
-
33
17
var connectionOpen = async ( ) => {
34
18
try {
35
19
var result = await connectToDatabase ( ) ;
@@ -48,8 +32,25 @@ var connectionClose = async () =>{
48
32
}
49
33
} ;
50
34
51
- connectionOpen ( ) ;
52
- connectionClose ( ) ;
35
+ app . post ( '/api/activity' , ( req , res ) => {
36
+
37
+ //Create the actual activity model instance
38
+ var newactivity = new activitymodel ( {
39
+ text :req . body . text ,
40
+ completed : req . body . completed
41
+ } ) ;
42
+
43
+ connectionOpen ( ) ;
44
+
45
+ //save the activity instance data to the document-tblactivities
46
+ newactivity . save ( ) . then ( ( doc ) => {
47
+ res . status ( 201 ) . send ( doc ) ;
48
+ connectionClose ( ) ;
49
+ } , ( err ) => {
50
+ res . status ( 400 ) . send ( err ) ;
51
+ connectionClose ( ) ;
52
+ } ) ;
53
+ } ) ;
53
54
54
55
app . listen ( PORT , ( ) => {
55
56
console . log ( `Server is up and running on port: ${ PORT } ` ) ;
You can’t perform that action at this time.
0 commit comments