Skip to content

Commit f726390

Browse files
authored
Fix the incorrect example of an afterResponse hook (#1115)
1 parent 982275e commit f726390

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

documentation/migration-guides.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,18 @@ const gotInstance = got.extend({
110110
}
111111
}
112112
],
113+
beforeRequest: [
114+
options => {
115+
if (options.responseType === 'json' && options.jsonReviver) {
116+
options.responseType = 'text';
117+
options.customJsonResponse = true;
118+
}
119+
}
120+
],
113121
afterResponse: [
114122
response => {
115123
const {options} = response.request;
116-
if (options.jsonReviver && options.responseType === 'json') {
117-
options.responseType = 'text';
124+
if (options.jsonReviver && options.customJsonResponse) {
118125
response.body = JSON.parse(response.body, options.jsonReviver);
119126
}
120127

0 commit comments

Comments
 (0)