Nuxt/examples/axios/README.md

39 lines
923 B
Markdown
Raw Normal View History

doc: create/update README.mds for examples (#4980) * Create README.md * Update README.md * Update README.md * Update README.md * Create README.md * Update README.md * Update README.md * Create README.md * Update README.md * Update README.md * Create README.md * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md * Create README.md * Update Readme.md * Create README.md * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md * Create README.md * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md * Create README.md * Create README.md * Update README.md * Create README.md * Create README.md * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md * Create README.md * Update README.md * Create README.md * Update README.md * Update README.md * Update README.md * Create README.md * Update README.md * Update examples/with-vuikit/README.md Co-Authored-By: husayt <husayt@gmail.com> * Update examples/auth-routes/README.md Co-Authored-By: husayt <husayt@gmail.com> * Update examples/middleware/README.md Co-Authored-By: husayt <husayt@gmail.com> * Update examples/vuex-store-modules/README.md Co-Authored-By: husayt <husayt@gmail.com> * Update examples/with-feathers/README.md Co-Authored-By: husayt <husayt@gmail.com> * Update examples/with-element-ui/README.md Co-Authored-By: husayt <husayt@gmail.com> * Update examples/with-cookies/README.md Co-Authored-By: husayt <husayt@gmail.com> * Update examples/vuex-store/README.md Co-Authored-By: husayt <husayt@gmail.com> * Update examples/vuex-persistedstate/README.md Co-Authored-By: husayt <husayt@gmail.com> * Update examples/with-firebase/README.md Co-Authored-By: husayt <husayt@gmail.com>
2019-02-08 14:48:30 +00:00
# Nuxt with Axios Proxy Example
Using [proxy-module](https://github.com/nuxt-community/proxy-module) and [Axios module](https://axios.nuxtjs.org/)
> proxy-module is the one-liner node.js http-proxy middleware solution for Nuxt.js using [http-proxy-middleware](https://github.com/chimurai/http-proxy-middleware)
> Axios-module is a secure and easy [Axios](https://github.com/mzabriskie/axios) integration with Nuxt.js.
2017-10-29 09:08:42 +00:00
## Install
```bash
$ yarn add @nuxtjs/axios @nuxtjs/proxy
```
## Nuxt.config.js
```json
{
modules: [
'@nuxtjs/axios',
'@nuxtjs/proxy'
],
proxy: [
['/api/dog', { target: 'https://dog.ceo/', pathRewrite: { '^/api/dog': '/api/breeds/image/random' } }]
]
}
```
### Use Axios
```js
async asyncData({ app }) {
const ip = await app.$axios.$get('http://icanhazip.com')
return { ip }
}
```
More detail, please refer [axios-module](https://github.com/nuxt-community/axios-module).