I am using createTask function to insert the document in mongodb atlas , the document is getting saved in atlas but catch part is also working and hence res.send after inserting document is not working.
const createTask=async (req,res)=>{
try{
const task = await Task.create(req.body);
// res.status(201).json({task});
res.send('done');
}
catch(err){res.status(500).json({msg:err});}
}
When I send the error using catch the error is coming as-
"msg": {
"code": 79,
"codeName": "UnknownReplWriteConcern",
"errInfo": {
"writeConcern": {
"w": "majority;",
"wtimeout": 0,
"provenance": "clientSupplied"
}
},
"name": "MongoWriteConcernError",
"result": {
"n": 1,
"opTime": {
"ts": "7021011505814437896",
"t": 192
},
"electionId": "7fffffff00000000000000c0",
"ok": 1,
"writeConcernError": {
"code": 79,
"codeName": "UnknownReplWriteConcern",
"errmsg": "No write concern mode named 'majority;' found in replica set configuration",
"errInfo": {
"writeConcern": {
"w": "majority;",
"wtimeout": 0,
"provenance": "clientSupplied"
}
}
},
"$clusterTime": {
"clusterTime": "7021011505814437896",
"signature": {
"hash": "C1HLM9Tmi+sPwFdXIPTEATVpmuA=",
"keyId": "6978775665008967681"
}
},
"operationTime": "7021011505814437896"
}
}
}