fix(plugin): allow reusing error.response.json

master
pooya parsa 2020-06-29 12:43:15 +02:00
parent 7023e162f4
commit 77b084bc01
1 changed files with 5 additions and 1 deletions

View File

@ -96,7 +96,11 @@ for (let method of ['get', 'head', 'delete', 'post', 'put', 'patch']) {
if (error.response) {
error.statusCode = error.response.status
try {
error.response.data = destr(await error.response.text())
const text = await error.response.text()
error.response.text = () => Promise.resolve(text)
const json = destr(text)
error.response.json = () => Promise.resolve(json)
error.response.data = json
} catch (_) { }
}