router.js
I have a function named controller, this is being called here -
let data = controller();
controller.js
function controller() {
//sendData below is a promise defined in another file, which is reading content of file and sending the data
sendData().then((data) => {
//perform some action on data
console.log(data)
return data;
}).catch((err) => {
return err;
})
}
The data being returned from the controller function is undefined, though i see data to be present in the success callback function on doing console.log
How to correctly return the data from the controller function? Thanks in advance.