Fix function contexts
This commit is contained in:
@@ -22,7 +22,7 @@ export default class Lndhub {
|
|||||||
async handleErroredRequest (result, retryFunction, args=[]) {
|
async handleErroredRequest (result, retryFunction, args=[]) {
|
||||||
console.warn('API request failed:', result.message);
|
console.warn('API request failed:', result.message);
|
||||||
if (result.code === 1) {
|
if (result.code === 1) {
|
||||||
return this.reauth().then(connected => {
|
return this.reauth().bind(this).then(connected => {
|
||||||
if (connected) {
|
if (connected) {
|
||||||
console.warn('Lndhub reconnected, trying again...');
|
console.warn('Lndhub reconnected, trying again...');
|
||||||
return this[retryFunction](...args);
|
return this[retryFunction](...args);
|
||||||
@@ -68,7 +68,8 @@ export default class Lndhub {
|
|||||||
let data = await this.callEndpoint('post', '/v2/invoices', payload);
|
let data = await this.callEndpoint('post', '/v2/invoices', payload);
|
||||||
|
|
||||||
if (data.error) {
|
if (data.error) {
|
||||||
return this.handleErroredRequest(data, 'createInvoice', Array.from(arguments));
|
return this.handleErroredRequest(data, 'createInvoice',Array.from(arguments))
|
||||||
|
.bind(this);
|
||||||
} else {
|
} else {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
@@ -78,7 +79,8 @@ export default class Lndhub {
|
|||||||
const data = await this.callEndpoint('get', `/v2/invoices/${paymentHash}`);
|
const data = await this.callEndpoint('get', `/v2/invoices/${paymentHash}`);
|
||||||
|
|
||||||
if (data.error) {
|
if (data.error) {
|
||||||
return this.handleErroredRequest(data, 'getInvoice', Array.from(arguments));
|
return this.handleErroredRequest(data, 'getInvoice', Array.from(arguments))
|
||||||
|
.bind(this);
|
||||||
} else {
|
} else {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user