mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-30 17:37:14 +00:00
c0311bc22f
* 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>
39 lines
923 B
Markdown
39 lines
923 B
Markdown
# 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.
|
|
|
|
## 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).
|