I am stuck with a problem here, where I want to keep my functions separately (in files) for a neater code.
In my Route.js, I am calling a function like this:
app.post('/pay', function(req, res){
User.getPaypal(function(output){
console.log(output) //i am not getting this result(output)
})
})
The function is exported in another file as below:
module.exports.getPaypal = function(){
var create_payment_json= {
//some values
};
paypal.payment.create(create_payment_json, function (err, payment) {
if (err) {
return err;
} else {
return payment;
}
});
}
I want to get a return value of payment or err as a return for the called function in the route.
How can I make this work?
console.log(output)?