documentation/migration-guides/axios.md
You may think it's too hard to switch, but it's really not. 🦄
Axios is very similar to Got. The difference is that Axios targets browsers first, while Got fully makes use of Node.js features.
These options remain the same as well:
We deeply care about readability, so we renamed these options:
httpAgent → agent.httphttpsAgent → agent.httpssocketPath → urlresponseEncoding → encodingauth.username → usernameauth.password → passworddata → body / json / formparams → searchParamstransformRequest → hooks.beforeRequest
transformResponse → hooks.afterResponse
baseUrl → prefixUrl
prefixUrl is always prepended to the url.timeout
responseType
'text', 'json' or 'buffer'.onUploadProgress
got(…).on('uploadProgress', …).onDownloadProgress
got(…).on('downloadProgress', …).maxContentLength
validateStatus
proxy
agent instead.cancelToken
signal option with AbortController.paramsSerializer
maxBodyLength
The response object is different as well:
response.data → response.bodyresponse.status → response.statusCoderesponse.statusText → response.statusMessageresponse.config → response.request.optionsresponse.request
The response.headers object remains the same.
Got offers hooks instead, which are more flexible.
Errors look the same, with the difference error.request returns a Got stream. Furthermore, Got provides more details to make debugging easier.
Got supports AbortController via the signal option.
Convenience methods, such as axios.get(…) etc. remain the same: got.get(…). Instead of axios.create(…) use got.extend(…).
Well, you have already come this far :tada:
Take a look at the documentation. It's worth the time to read it.
There are some great tips.
If something is unclear or doesn't work as it should, don't hesitate to open an issue.