2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-02 16:04:10 +03:00

Add HTTP basic authentication.

This commit is contained in:
Harry Lachenmayer
2015-10-20 19:42:19 +01:00
committed by Idan Gazit
parent 4bbde9ae6c
commit 32a904394f
+9 -2
View File
@@ -39,10 +39,17 @@ module.exports = function xhrAdapter(resolve, reject, config) {
xDomain = true;
}
// HTTP basic authentication
var configAuth = config.auth || {};
var auth = {
username: configAuth.username || configAuth.user || '',
password: configAuth.password || configAuth.pass || ''
};
// Create the request
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
request.timeout = config.timeout;