Skip to content

Instantly share code, notes, and snippets.

@Mosharush
Last active October 18, 2018 21:10
Show Gist options
  • Save Mosharush/0d7bddedbb3212cd830e125b161add0c to your computer and use it in GitHub Desktop.
Save Mosharush/0d7bddedbb3212cd830e125b161add0c to your computer and use it in GitHub Desktop.
Nuxt.js 2.2.0 - Fix Error Cannot stringify arbitrary non-POJOs
/**
* 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;
});
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