Migration Guides
How to migrate from Axios module
This guide will help you to migrate from Axios Module.
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
onRequestErrorandonResponseErrorare unified
Use theonErrorhook instead - The http module does not have a
debugoption like the axios module
You can setup a basic logger using theonRequesthook - Progress bar integration is not supported (for the moment)
This option may be added again oncePR #105 : progress baris 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
jsonon 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')Table of Contents