Nuxt/examples/axios
2018-07-12 14:03:50 +02:00
..
pages refactor: use eslint-plugin-vue instead of eslint-plugin-html (#3517) 2018-07-12 14:03:50 +02:00
nuxt.config.js feat: rewrite core to esm 2018-03-16 19:42:06 +03:30
package.json misc: use nuxt-edge in partial examples 2018-04-12 18:25:44 +08:00
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.