Skip to content

Commit c630a8a

Browse files
committed
Add language to code snippets. Fixes #184
1 parent 3df4092 commit c630a8a

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ Most errors are likely to be those raised by the API in response to the request.
431431

432432
To handle errors with `jsonapi-vuex` using `then/catch` methods on the promise:
433433

434-
```
434+
```js
435435
this.$store
436436
.dispatch('jv/get', '/widget/99')
437437
.then((res) => {
@@ -455,7 +455,7 @@ this.$store
455455

456456
Otherwise if you are using `async/await`:
457457

458-
```
458+
```js
459459
try {
460460
let res = await this.$store.dispatch('jv/get', '/widget/99')
461461
console.log(res)
@@ -472,7 +472,7 @@ The status of actions can be monitored using the `status` wrapper function, impo
472472

473473
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:
474474

475-
```
475+
```js
476476
import { status } from 'jsonapi-vuex'
477477

478478
// Capture the returned promise
@@ -503,9 +503,9 @@ The value for the ID in `status.status` will be set to one of:
503503
- 1 - Action is Complete (Success)
504504
- -1 - Action is Complete (Error)
505505

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:
507507

508-
```
508+
```js
509509
// Change the status values at the start
510510
status.PENDING = 'Please wait...'
511511
status.SUCCESS = 'Task completed successfully'
@@ -514,7 +514,7 @@ status.ERROR = 'There was an error'
514514

515515
You can now easily track status in your UI:
516516

517-
```
517+
```html
518518
<!-- Displayed once action completes (success or error) -->
519519
<span v-if="myStatus">{{ result }}</span>
520520

@@ -618,7 +618,7 @@ Updates records in the store. Replaces or merges with existing records, dependin
618618

619619
`addRecords` takes a normalised data object as an argument.
620620

621-
```
621+
```js
622622
// Update a single record in ths store
623623
store.commit(
624624
'jv/addRecords',
@@ -680,7 +680,7 @@ Distinguishing between the `attributes` and `relationships` in the 'root' is sim
680680

681681
These are particularly useful in `Vue` templates. For example to iterate over an item, picking out just the attributes:
682682

683-
```
683+
```html
684684
<li v-for="(val, key) in widget._jv.attrs">{{ key }} {{ val }}</li>
685685

686686
<!-- Or -->
@@ -694,7 +694,7 @@ These are particularly useful in `Vue` templates. For example to iterate over an
694694

695695
Some functions are potentially useful for data manipulation etc outside the normal code flow. These functions are exported as `utils`, i.e:
696696

697-
```
697+
```js
698698
import { utils } from `jsonapi-vuex`
699699
```
700700

@@ -777,7 +777,7 @@ However many APIs vary how endpoints are named - for example plurals (e.g. `type
777777

778778
To solve this it is possible to override the endpoint for a request by explicitly setting the `axios` `url` configuration option:
779779

780-
```
780+
```js
781781
data = { _jv: { type: 'person' } }
782782

783783
// Default behaviour - will always treat type = itemEP = collectionEP

0 commit comments

Comments
 (0)