Answer the question
In order to leave comments, you need to log in
How to properly deal with this in classes?
There is this class:
class ParserRSS {
constructor(FeedParser, request) {
this.feedParser = new FeedParser();
}
request(url) {
const req = this.request(url);
req.on('response', function(res) {
this.pipe(this.feedParser);
});
}
}
this.pipe(this.feedParser);
. There, the first this from the callback should be, and the second should be a property of the class (which is set when the constructor is called). How can I make it clear to the code where this is?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question