1.0.0 • Published 6 years ago

example-axios v1.0.0

Weekly downloads
4
License
-
Repository
-
Last release
6 years ago

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.