2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-17 19:21:29 +03:00

Allow unsetting headers by passing null (#382) (#1845)

Co-authored-by: Jay <jasonsaayman@gmail.com>
This commit is contained in:
Martti Laine
2020-06-04 20:57:54 +02:00
committed by GitHub
parent 4b3947aa59
commit 487941663b
4 changed files with 33 additions and 6 deletions
+7
View File
@@ -47,6 +47,13 @@ module.exports = function dispatchRequest(config) {
}
);
// Remove header where value is null
utils.forEach(config.headers, function deleteNullValueHeaders(value, key) {
if (value === null) {
delete config.headers[key];
}
});
var adapter = config.adapter || defaults.adapter;
return adapter(config).then(function onAdapterResolution(response) {
+5
View File
@@ -294,6 +294,11 @@ function deepMerge(/* obj1, obj2, obj3, ... */) {
}
}
var lastArgument = arguments[arguments.length - 1];
if (lastArgument === null || typeof lastArgument === 'undefined') {
return lastArgument;
}
for (var i = 0, l = arguments.length; i < l; i++) {
forEach(arguments[i], assignValue);
}