Have a look on my controller
exports.userList = async (req, res) => {
let result = await Methods.getAllData(Campaign)
await console.log(result, 'tr')
}
Here Methods.getAllData
is a function to get all user data and the parameter Campaign
is my Model name.
here the function..
methods.getAllData = (modelName)=>{
modelName.findAll({
}).then(value=>{
console.log(value, 'rt')
return value
}).catch(err=>{
return err
})
}
My console.log statement is running first. I have tried to solve using aync/await but not working. I need to get the result and then I need to console that.
Here I have returned the data, how can I use callback as replacement of return?