mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 16:43:55 +00:00
.. | ||
pages | ||
nuxt.config.js | ||
package.json | ||
README.md |
Axios Proxy Example
Install
$ yarn add @nuxtjs/axios @nuxtjs/proxy
Nuxt.config.js
{
modules: [
'@nuxtjs/axios',
'@nuxtjs/proxy'
],
proxy: [
['/api/dog', { target: 'https://dog.ceo/', pathRewrite: { '^/api/dog': '/api/breeds/image/random' } }]
]
}
Use Axios
async asyncData({ app }) {
const ip = await app.$axios.$get('http://icanhazip.com')
return { ip }
}
More detail, please refer axios-module.