Update readme with how to use in component methods

The readme isn't super clear on how to use the module outside of the specific cases that are mentioned in the _Usage_ section. This just adds a small example of using it in the component `methods`.
master
Sam Garson 2017-10-26 16:57:44 +01:00 committed by Pooya Parsa
parent bbee76048c
commit 34670079fa
1 changed files with 15 additions and 2 deletions

View File

@ -35,7 +35,7 @@
- [Features](#features)
- [Setup](#setup)
- [Usage](#usage)
- [Component](#component-asyncdata)
- [Component](#component)
- [Store](#store-nuxtserverinit)
- [Store Actions](#store-actions)
- [Options](#options)
@ -93,7 +93,9 @@ Install with yarn:
## Usage
### Component `asyncData`
### Component
**`asyncData`**
```js
async asyncData({ app }) {
@ -102,6 +104,17 @@ async asyncData({ app }) {
}
```
**`methods`/`created`/`mounted`/etc**
```js
methods: {
async fetchSomething() {
const ip = await this.$axios.$get('http://icanhazip.com')
this.ip = ip
}
}
```
### Store `nuxtServerInit`
```js
async nuxtServerInit ({ commit }, { app }) {