Reputation: 593
I am new to sailsJS. I want to add record in collection named skills.
I have refered this document of sails js https://sailsjs.com/documentation/reference/waterline-orm/models/create
I have request as :
{
"skillName": "tblPreffered PartneersTest",
"active": "true"
}
my function is :
FnCreate : function(req,res){
var Data = await Skills.create(req.body).exec().fetch();
console.log('data is :'+JSON.stringify(Data));
res.send({
status : true,
statusCode : 200,
message : "New Skill added",
responce : Data,
})
}
now when i run, it says error as :
var Data = await Skills.create(req.body).exec().fetch();
^^^^^^^^^^^^^^^^^
SyntaxError: Unexpected identifier
can any one help me what should I do ?
Upvotes: 0
Views: 280
Reputation: 1255
You need you use async
keyword :
FnCreate : async function(req,res){
var Data = await Skills.create(req.body).fetch();
console.log('data is :'+JSON.stringify(Data));
res.send({
status : true,
statusCode : 200,
message : "New Skill added",
responce : Data,
})
}
Upvotes: 2