Answer the question
In order to leave comments, you need to log in
How to get headers to pipe?
There is such a code. I make a request, stream a file. But in order to save this file, I need to get its permission, which is in the header, but pipe fires before the on('response') event. How to get headers before the pipe starts?
const url = 'http://localhost:3589/file/upload?fileName=qwe.json'
let ext, id;
request.get(url)
.on('response', function (response) {
ext = response.headers['file-ext'];
id = response.headers['stream-id'];
})
.pipe(createWriteStream(`doodle.${ext}`))
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