mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-30 17:37:14 +00:00
ee7ad7741e
[skip ci] |
||
---|---|---|
.. | ||
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.