2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-20 20:00:40 +03:00

Fix: Removes usage of deprecated Buffer constructor. (#1555) (#1622)

This commit is contained in:
Mark van den Broek
2018-07-05 08:47:17 +02:00
committed by Justin Beckwith
parent d74238e151
commit 787c808c04
2 changed files with 9 additions and 9 deletions
+3 -3
View File
@@ -39,9 +39,9 @@ module.exports = function httpAdapter(config) {
if (Buffer.isBuffer(data)) {
// Nothing to do...
} else if (utils.isArrayBuffer(data)) {
data = new Buffer(new Uint8Array(data));
data = Buffer.from(new Uint8Array(data));
} else if (utils.isString(data)) {
data = new Buffer(data, 'utf-8');
data = Buffer.from(data, 'utf-8');
} else {
return reject(createError(
'Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream',
@@ -124,7 +124,7 @@ module.exports = function httpAdapter(config) {
// Basic proxy authorization
if (proxy.auth) {
var base64 = new Buffer(proxy.auth.username + ':' + proxy.auth.password, 'utf8').toString('base64');
var base64 = Buffer.from(proxy.auth.username + ':' + proxy.auth.password, 'utf8').toString('base64');
options.headers['Proxy-Authorization'] = 'Basic ' + base64;
}
}