Update utils.js

This commit is contained in:
Aleksandr Statciuk 2022-03-30 23:04:04 +03:00
parent e86ec4bd31
commit 4f0a7697e6
1 changed files with 9 additions and 5 deletions

View File

@ -316,11 +316,15 @@ utils.getUTCDate = function (d = null) {
}
utils.parseResponse = async (item, response, config) => {
const content =
utils.isObject(response.data) || Array.isArray(response.data)
? JSON.stringify(response.data)
: response.data.toString()
const buffer = Buffer.from(content, 'utf8')
let buffer
let content
if (utils.isObject(response.data) || Array.isArray(response.data)) {
content = JSON.stringify(response.data)
buffer = Buffer.from(content, 'utf8')
} else {
content = response.data.toString()
buffer = response.data
}
const data = merge(item, config, {
content,
buffer,