Answer the question
In order to leave comments, you need to log in
How to put header in http.get?
I read https://nodejs.org/api/http.html#http_http_get_opt...
I did not understand anything and everything I tried does not work.
Here is my code
const options = url.parse(imgUrl);
let client;
if (options.protocol === 'https:') {
client = https;
} else if (options.protocol === 'http:') {
client = http;
} else {
throw new Error('The string should have "http" or "https" scheme.');
}
const req = client.get(options, function(response) {
...
}
Answer the question
In order to leave comments, you need to log in
client.get({path: 'https://...', headers: {'x-header': 'header value'}}, (res) => {})
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question