mirror of
https://github.com/tenrok/axios.git
synced 2026-06-20 20:00:40 +03:00
Add HTTP basic authentication.
This commit is contained in:
committed by
Idan Gazit
parent
4bbde9ae6c
commit
32a904394f
+9
-2
@@ -39,10 +39,17 @@ module.exports = function xhrAdapter(resolve, reject, config) {
|
|||||||
xDomain = true;
|
xDomain = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HTTP basic authentication
|
||||||
|
var configAuth = config.auth || {};
|
||||||
|
var auth = {
|
||||||
|
username: configAuth.username || configAuth.user || '',
|
||||||
|
password: configAuth.password || configAuth.pass || ''
|
||||||
|
};
|
||||||
|
|
||||||
// Create the request
|
// Create the request
|
||||||
var request = new adapter('Microsoft.XMLHTTP');
|
var request = new adapter('Microsoft.XMLHTTP');
|
||||||
request.open(config.method.toUpperCase(), buildURL(config.url, config.params, config.paramsSerializer), true);
|
request.open(config.method.toUpperCase(), buildURL(config.url, config.params, config.paramsSerializer), true, auth.username, auth.password);
|
||||||
|
|
||||||
// Set the request timeout in MS
|
// Set the request timeout in MS
|
||||||
request.timeout = config.timeout;
|
request.timeout = config.timeout;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user