Add 'request' property

master
KaKi87 2022-07-14 16:54:54 +02:00
parent 4937cd856c
commit 355e8d09c1
1 changed files with 8 additions and 6 deletions

View File

@ -33,11 +33,7 @@ export default config => new Promise((resolve, reject) => {
console.warn(`Timeout of ${config.timeout}ms rounded to ${timeout}ms`);
try {
const
{
status,
headers,
data
} = await (await getClient({
request = (await getClient({
maxRedirections: config.maxRedirects
})).request({
url: buildURL(buildFullPath(config.baseURL, config.url), config.params, config.paramsSerializer),
@ -65,6 +61,11 @@ export default config => new Promise((resolve, reject) => {
timeout: timeout / 1000,
responseType: http.ResponseType.Binary
}),
{
status,
headers,
data
} = await request,
binaryData = data.length && new Uint8Array(data),
textData = binaryData && (() => { try { return new TextDecoder().decode(binaryData); } catch {} })(),
jsonData = textData && (() => { try { return JSON.parse(textData); } catch {} })();
@ -79,7 +80,8 @@ export default config => new Promise((resolve, reject) => {
status,
statusText: ReasonPhrases[StatusCodes[status]],
headers,
config
config,
request
});
}
catch(error){