Skip to content

Commit

Permalink
Fix the incorrect example of an afterResponse hook (#1115)
Browse files Browse the repository at this point in the history
  • Loading branch information
rifler committed Mar 11, 2020
1 parent 982275e commit f726390
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions documentation/migration-guides.md
Expand Up @@ -110,11 +110,18 @@ const gotInstance = got.extend({
}
}
],
beforeRequest: [
options => {
if (options.responseType === 'json' && options.jsonReviver) {
options.responseType = 'text';
options.customJsonResponse = true;
}
}
],
afterResponse: [
response => {
const {options} = response.request;
if (options.jsonReviver && options.responseType === 'json') {
options.responseType = 'text';
if (options.jsonReviver && options.customJsonResponse) {
response.body = JSON.parse(response.body, options.jsonReviver);
}

Expand Down

0 comments on commit f726390

Please sign in to comment.