Nuxt/examples/axios
2019-01-22 11:04:19 +03:30
..
pages feat: upgrade eslint to 5.x (#3494) 2018-08-31 21:34:12 +01:00
nuxt.config.js feat: rewrite core to esm 2018-03-16 19:42:06 +03:30
package.json fix(examples): fix deps on codesandbox (#4828) 2019-01-22 11:04:19 +03:30
README.md feat: add axios and proxy example 2017-10-29 17:08:42 +08:00

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.