You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+10-10Lines changed: 10 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -431,7 +431,7 @@ Most errors are likely to be those raised by the API in response to the request.
431
431
432
432
To handle errors with `jsonapi-vuex` using `then/catch` methods on the promise:
433
433
434
-
```
434
+
```js
435
435
this.$store
436
436
.dispatch('jv/get', '/widget/99')
437
437
.then((res) => {
@@ -455,7 +455,7 @@ this.$store
455
455
456
456
Otherwise if you are using `async/await`:
457
457
458
-
```
458
+
```js
459
459
try {
460
460
let res =awaitthis.$store.dispatch('jv/get', '/widget/99')
461
461
console.log(res)
@@ -472,7 +472,7 @@ The status of actions can be monitored using the `status` wrapper function, impo
472
472
473
473
It returns the promise created by the function, with an ID added (`_statusID`). This ID can be used to get the status of the function via the `status.status` object:
474
474
475
-
```
475
+
```js
476
476
import { status } from'jsonapi-vuex'
477
477
478
478
// Capture the returned promise
@@ -503,9 +503,9 @@ The value for the ID in `status.status` will be set to one of:
503
503
- 1 - Action is Complete (Success)
504
504
- -1 - Action is Complete (Error)
505
505
506
-
These values can be easily overidden if you wish to use the value directly:
506
+
These values can be easily overridden if you wish to use the value directly:
507
507
508
-
```
508
+
```js
509
509
// Change the status values at the start
510
510
status.PENDING='Please wait...'
511
511
status.SUCCESS='Task completed successfully'
@@ -514,7 +514,7 @@ status.ERROR = 'There was an error'
514
514
515
515
You can now easily track status in your UI:
516
516
517
-
```
517
+
```html
518
518
<!-- Displayed once action completes (success or error) -->
519
519
<spanv-if="myStatus">{{ result }}</span>
520
520
@@ -618,7 +618,7 @@ Updates records in the store. Replaces or merges with existing records, dependin
618
618
619
619
`addRecords` takes a normalised data object as an argument.
620
620
621
-
```
621
+
```js
622
622
// Update a single record in ths store
623
623
store.commit(
624
624
'jv/addRecords',
@@ -680,7 +680,7 @@ Distinguishing between the `attributes` and `relationships` in the 'root' is sim
680
680
681
681
These are particularly useful in `Vue` templates. For example to iterate over an item, picking out just the attributes:
682
682
683
-
```
683
+
```html
684
684
<liv-for="(val, key) in widget._jv.attrs">{{ key }} {{ val }}</li>
685
685
686
686
<!-- Or -->
@@ -694,7 +694,7 @@ These are particularly useful in `Vue` templates. For example to iterate over an
694
694
695
695
Some functions are potentially useful for data manipulation etc outside the normal code flow. These functions are exported as `utils`, i.e:
696
696
697
-
```
697
+
```js
698
698
import { utils } from`jsonapi-vuex`
699
699
```
700
700
@@ -777,7 +777,7 @@ However many APIs vary how endpoints are named - for example plurals (e.g. `type
777
777
778
778
To solve this it is possible to override the endpoint for a request by explicitly setting the `axios``url` configuration option:
779
779
780
-
```
780
+
```js
781
781
data = { _jv: { type:'person' } }
782
782
783
783
// Default behaviour - will always treat type = itemEP = collectionEP
0 commit comments