I'm attempting to call nested async functions inside a class, if that's even possible with the new async / await feature in 2017.
Heres some example code, which I'm running with NodeJS v7.7.2:
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class Counter {
async run() {
await this.one();
await this.two();
await this.three();
return new Promise(function (resolve) {
});
}
async one() {
console.log('one');
return new Promise(function (resolve) {
});
}
async two() {
console.log('two');
return new Promise(function (resolve) {
});
}
async three() {
console.log('three');
return new Promise(function (resolve) {
});
}
}
exports.Counter = Counter;
let counter = new Counter();
counter.run();
What I'm expecting to happen is this code to print one two three
However, it only prints one
It seems that the subsequent calls to this.two() and this.three are not being made. Been trying to debug this problem for a couple of days.
via aussieguy123
No comments:
Post a Comment