When I use then to return “this” with its callback it starts an infinite loop of calling then. I don't get why:
class ApiRequest {
constructor() {
}
then(ready) {
console.log('then start');
ready(this)
console.log('then end');
}
}
let apiRequest = new ApiRequest;
await apiRequest;
console:
then start
then end
then start
then end
then start
then end
then start
then end
then start
then end
then start
then end
then start
then end
then start
then end
then start
then end
...
With .then style it works perfectly:
let apiRequest = new ApiRequest;
apiRequest.then(apiResponse => {
console.log('apiResponse', apiResponse)
});
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
When I use then to return “this” with its callback it starts an infinite loop of calling then. I don't get why:
console:
With .then style it works perfectly: