I have a problem with my project. I'm trying to set API request and once it done I want to store the res in var.
My code:
function getMyBtcBalace(){
return new Promise((resolve, reject) =>{
bit2c.getBalance(credentials, function(error, balance) {
resolve(balance.BTC);
//return
})
});
}
///After API call
var temp = getMyBtcBalace();
In my project I want to get the updatest value of balace.BTC every time I call getMyBtcBalace function.
As you can see I use Promise, but I don't want continue coding in then() function.
Example:
function AsyncFunc(){
///// Async
}
function getMyBtcBalace(){
return new Promise((resolve, reject) =>{
bit2c.getBalance(credentials, function(error, balance) {
resolve(balance.BTC);
//return
})
});
}
while (getMyBtcBalace() > AsyncFunc2())
{
/// Do something
}