Nuxt/examples/axios
pooya parsa e7cc2757c3 refactor: update eslint-config to 1.x
Co-authored-by: Alexander Lichter <manniL@gmx.net>
2019-07-10 15:15:49 +04:30
..
pages refactor: update eslint-config to 1.x 2019-07-10 15:15:49 +04:30
README.md doc: create/update README.mds for examples (#4980) 2019-02-08 15:48:30 +01:00
nuxt.config.js feat: rewrite core to esm 2018-03-16 19:42:06 +03:30
package.json chore(examples): rebase on latest stable nuxt version (#4874) 2019-02-01 16:36:06 +03:30

README.md

Nuxt with Axios Proxy Example

Using proxy-module and Axios module

proxy-module is the one-liner node.js http-proxy middleware solution for Nuxt.js using http-proxy-middleware

Axios-module is a secure and easy Axios integration with Nuxt.js.

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.