I am currently trying to use the got module https://www.npmjs.com/package/got but I am a bit confused on the format/order of functions. It's evident that you can chain the listeners and functions as such
got.stream(link)
.on('response', resp => {
if (resp.statusCode != 200) this.emit('error', '!200')
})
.on('error', err => {
console.log(err)
})
.pipe(somewhere)
The request module also does this. But how do you avoid .pipe
if you want it to happen only on the condition resp.statusCode != 200
? Seeing that it's used in a lot of request modules, it must be a very basic thing to understand but I can't quite grasp it.
via platizin
No comments:
Post a Comment