I am facing an issue with the second res.json
. I have attempted the following:
res.json({500,message : 'xxxxxx'})
res.send({500,message : 'xxxxxx'})
However, the problem persists. Here is my code snippet:
import mongoose from 'mongoose';
import {Router} from 'express';
import Motor from '../model/motor';
export default({config,db}) =>{
let api = Router();
// '/v1/motor/add'
api.post('/add',(res,req) => {
let newMotor = new Motor();
newMotor.title = req.body.title;
newMotor.save(err = {
if(err){
res.json({message : 'error'});
}
res.json({message : 'motor saved successfully'});
});
});
return api;
}
Here is the error message being displayed:
SyntaxError: C:/Users/Ali Baltschun/Desktop/motorDB/src/controller/motor.js: Unexpected token, expected , (17:6)
15 | res.json({message : 'error'});
16 | }
> 17 | res.json({message : 'motor saved successfully'});
| ^
18 | });
19 | });