Hi, i am fairly new to node js development and I am trying to build a back-end using node js and i have created a following controller in my code.
exports.bridge_b2b_transfer = function(req, res, next){
let data = bnb.Transfer_b2b(req.body.bnb_wallet)
console.log(data)
}
But it returns empty data.
I have tried to converting calls to asyncawait but with no success.and then i tried to use callbacks but grasping the concept is really difficult for me.
httpClient
.get(sequenceURL)
.then((res) => {
const sequence = res.data.sequence || 0
return bnbClient.transfer(addressFrom, addressTo, amount, asset, message, sequence)
})
.then((result) => {
console.log(result);
if (result.status === 200) {
console.log('success', result.result[0].hash);
} else {
console.error('Error: ', result);
}
})
.catch((error) => {
console.error('error :', error);
return error
});
Output is printed where console is used but i want to return data to my main controller which is calling this function from another file. But as it is, it doesn't and data is undefined.