Last active
October 18, 2018 21:10
-
-
Save Mosharush/0d7bddedbb3212cd830e125b161add0c to your computer and use it in GitHub Desktop.
Nuxt.js 2.2.0 - Fix Error Cannot stringify arbitrary non-POJOs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* plugins/axios-middleware.js | |
*/ | |
import axios from 'axios'; | |
axios.interceptors.response.use(response => { | |
if( typeof response.data === 'object' && response.data.constructor !== Array ) { | |
response.data = Object.assign({}, response.data); | |
} | |
return response; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
process.env.DEBUG = 'nuxt:*'; | |
module.exports = { | |
........ | |
plugins: [ | |
'@plugins/axios-middleware.js', <---- Add the middleware to nuxt config in plugins section | |
....... | |
], | |
modules: [ | |
..... | |
], | |
....... | |
/* | |
** Build configuration | |
*/ | |
build: { | |
...... | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment