mirror of https://github.com/sundowndev/http.git
1.7 KiB
1.7 KiB
Migration Guide
This guide will help you to migrate from Axios Module.
:::tip Note The nuxt-community axios module is still supported and maintained. The HTTP module uses newer web technologies like fetch which might be beneficial :::
Differences
- There is no scope for
setHeader
,setToken
When calling these methods they apply to the global scope and are used for all future requests - The axios hooks
onRequestError
andonResponseError
are unified
Use theonError
hook instead - The http module does not have a
debug
option like the axios module
You can setup a basic logger using theonRequest
hook - Progress bar integration is not supported (for the moment)
This option may be added again oncePR #34: Add 'onProgress' option
for ky is merged
Response body parsing
Axios automatically transforms response bodies to JSON, if you wish to keep that behaviour you will
- either need to switch to using the
$
prefixed methods
-- const resJson = await this.$axios.get('/url')
++ const resJson = await this.$http.$get('/url')
- or explicitly call
json
on the Response:
-- const resJson = await this.$axios.get('/url')
++ const resJson = await this.$http.get('/url').json()
If you are already using $
prefixed shortcuts for making requests that return JSON, you can keep using them.
-- const resJson = await this.$axios.$get('/url')
++ const resJson = await this.$http.$get('/url')