function send_cash_toClient_QIWI(){ this.phone = this.tradeoffer.phone_number; this.amount = this.tradeoffer.amount; let msgProccess = (msg.send + this.phone + ' Количество: ' + this.amount + ' руб.'); return this.message(msgProccess).then((text) => { return qiwi.send(One, this.amount, this.phone).then((status) => { if(status){ console.log(this.id + ': ' + 'qiwi money was send'); this.payed = true; this.save({'pay': true}); return this.message(msg.success).then((status) => { return client.markpaid(this.id).then((status)=>{ return ('Marked as Payed'); }) }) } else { return ('error send cash'); } }) }) } each function inside the send_cash_toClient function contains a promise (return new Promise) and returns resolve, so after each function .then ((status), and I call this function (send_cash_toClie ....) via await / async if I did not overdo it with return I originally wrote this
function send_cash_toClient_QIWI(){ this.phone = this.tradeoffer.phone_number; this.amount = this.tradeoffer.amount; let msgProccess = (msg.send + this.phone + ' Количество: ' + this.amount + ' руб.'); return new Promise((resolve, reject) => { this.message(msgProccess).then((text) => { qiwi.send(One, this.amount, this.phone).then((status) => { if(status){ console.log(this.id + ': ' + 'qiwi money was send'); this.payed = true; this.save({'pay': true}); this.message(msg.success).then((status) => { client.markpaid(this.id).then((status)=>{ resolve('Marked as Payed') }) }) } else { resolve('error send cash') } }) }) }) } How correct? and so that there are no piles