test: got axios options

This commit is contained in:
DIYgod
2019-06-14 17:51:03 +08:00
parent 6dfaecaf58
commit 56e74742fc
3 changed files with 38 additions and 27 deletions

View File

@@ -69,21 +69,12 @@ const custom = got.extend({
return response;
},
],
onError: [
(error) => {
error.response.status = error.response.statusCode;
return error;
},
],
init: [
(options) => {
// compatible with axios api
if (options.data) {
options.body = options.body || options.data;
}
if (options.responseType === 'buffer') {
options.encoding = null;
}
if (options.params) {
options.query = options.query || queryString.stringify(options.params);
options.searchParams = options.query; // for Got v11 after