ethanent / phin

Node HTTP client
MIT License
576 stars 33 forks source link

How to use http-auth? #41

Closed ashraful-islam closed 5 years ago

ashraful-islam commented 5 years ago

Hello!

I looked through documentation & source code, but neither mentions how to provide authorization parameters.

For example, in axios, there is a configuration parameter auth used to pass the username, password to perform a request to protected service.

How do I pass these parameters in phin?

Thanks!

jumoog commented 5 years ago

its just a normal HTTP Header

var header = user + ':' + pass;
header = Buffer.from(header, 'utf8').toString('base64');
var authHeader = 'Basic ' + header;
ethanent commented 5 years ago

Thank you, @jumoog.