Skip to content

Commit 8e4ba96

Browse files
committed
docs(api): general formatting and description updates
1 parent 91280eb commit 8e4ba96

File tree

3 files changed

+91
-70
lines changed

3 files changed

+91
-70
lines changed

docs/api/model.md

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,42 +4,49 @@ sidebarDepth: 2
44

55
# Model
66

7-
Vuex ORM Axios adds a few properties and methods to the Model object.
7+
Vuex ORM Axios adds supporting properties and methods to the `Model` object.
88

99
## Static Properties
1010

11-
### axios
11+
### `axios`
1212

13-
- **`static axios: AxiosInstance | null`**
13+
- **Type**: `AxiosInstance | null`
1414

15-
The axios isntance which was installed during the plugin installation process. Vuex ORM Axios adds a few properties and methods to the Model object. Vuex ORM Axios will use this Axios instance to perform any HTTP request.
15+
The axios instance which was either set during plugin installation or set using the [`setAxios`](#setaxios) method. Vuex ORM Axios will use this axios instance to perform requests.
1616

17-
Usually, this property will not become `null`. However, there's a case where you may need to add Axios instance manually, for example, when using Vuex ORM Axios with Nuxt.js. In that case, this property will temporarily be `null`.
17+
### `apiConfig`
1818

19-
### globalApiConfig
19+
- **Type**: `Object`
20+
- **Default**: `{}`
2021

21-
- **`globalApiConfig: GlobalConfig`**
22+
The property that holds the model configuration for requests.
2223

23-
The property that holds global configuration. The value will be set automatically during the plugin installation process. **Do not mutate this property manually**.
24+
### `globalApiConfig`
2425

25-
- **`apiConfig: Config | null`**
26+
- **Type**: `Object`
2627

27-
The property that defines the Model configuration for the API call.
28+
The property that holds the global configuration. The value will be set automatically during the plugin installation process.
29+
30+
::: warning WARNING
31+
Do not mutate this property programmatically.
32+
:::
2833

2934
## Static Methods
3035

31-
### setAxios
36+
### `api`
37+
38+
- `api(): Request`
3239

33-
- **`static setAxios(axios: AxiosInstance): void`**
40+
Return a newly created [Request](request) instance.
3441

35-
The method to set the Axios instance manually. Usually, you don't have to call this method yourself; however, you might need to use this method to set Axios instance properly in some situations. Please [refer here](../guide/getting-started.html#nuxt-js-integration) for more detail.
42+
### `setAxios`
3643

37-
### api
44+
- `setAxios(axios: AxiosInstance): void`
3845

39-
- **`static api(): Request`**
46+
Set the axios instance manually. Typical setups will configure the axios instance during installation. However, in some cases (mostly with Nuxt), you may need to set the axios instance at a later stage.
4047

41-
This method is going to return a new Request instance. A request instance is the wrapper for Axios, and it's used to perform any API request.
48+
::: warning IMPORTANT
49+
If you omit the axios instance during installation, it's important that one is set using `setAxios` before any attempt to make an API request.
50+
:::
4251

43-
```js
44-
User.api().get('/api/users')
45-
```
52+
**See also**: [Nuxt.js Integration](../guide/setup.md#nuxt-js-integration)

docs/api/request.md

Lines changed: 38 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,74 +4,82 @@ sidebarDepth: 2
44

55
# Request
66

7-
The Request object is the foundation for the Vuex ORM Axios, and you can call many methods to perform an api request. You can obtain a Request instance by `api` method on the Model.
7+
The Request object is returned when calling the `api()` method on a model. This object is the foundation for Vuex ORM Axios and enables you to call many of the supported axios methods to perform an API request. Any [Custom Actions](../guide/custom-actions) will also be defined on the Request object.
88

99
```js
1010
const request = User.api()
1111
```
1212

13-
Usually, you could just call Request methods directly by method chaining.
13+
You can call request methods directly through chaining.
1414

1515
```js
16-
User.api().get()
16+
const response = User.api().get()
1717
```
1818

1919
## Constructor
2020

21-
- **``constructor(model: typeof Model)``**
21+
- `constructor(model: typeof Model)`
2222

23-
Request instances require the Model class to be passed to the constructor. It's automatically done when obtaining the Request object through `Model.api()` method. Alternatively, you could manually construct Request object your self.
23+
By default, calling the `api()` method on a model will attach the model class to the Request object.
24+
25+
You may also create a Request instance by passing a model as the constructors only param.
2426

2527
```js
26-
// This is equivalent to...
27-
const request = new Request(User)
28+
import { Request } from '@vuex-orm/plugin-axios'
2829

29-
// This.
30-
const request = User.api()
30+
const request = new Request(User)
3131
```
3232

3333
## Instance Properties
3434

35-
### model
35+
### `model`
3636

37-
- **`model: typeof Model`**
37+
- **Type**: `typeof Model`
3838

39-
The Model class that is attached to the Request instance.
39+
The model class that is attached to the Request instance.
4040

41-
### axios
41+
### `axios`
4242

43-
- **`axios: AxiosInstance`**
43+
- **Type**: `AxiosInstance`
4444

45-
The Axios instance that will be used to perform the request.
45+
The axios instance that will be used to perform the request.
4646

4747
## Instance Methods
4848

49-
### get
49+
### `get`
50+
51+
- `get(url: string, config: Config = {}): Promise<Response>`
52+
53+
Performs a `GET` request. It takes the same arguments as the axios `get` method.
54+
55+
### `post`
56+
57+
- `post(url: string, data: any = {}, config: Config = {}): Promise<Response>`
5058

51-
- **`get(url: string, config: Config = {}): Promise<Response>`**
59+
Performs a `POST` request. It takes the same arguments as the axios `post` method.
5260

53-
Performs a `GET` request. It takes the same argument as Axios's `get` method.
61+
### `put`
5462

55-
### post
63+
- `put(url: string, data: any = {}, config: Config = {}): Promise<Response>`
5664

57-
- **`post(url: string, data: any = {}, config: Config = {}): Promise<Response>`**
65+
Performs a `PUT` request. It takes the same arguments as the axios `put` method.
5866

59-
Performs a `POST` request. It takes the same argument as Axios's `post` method.
67+
### `patch`
6068

61-
### put
69+
- `patch(url: string, data: any = {}, config: Config = {}): Promise<Response>`
6270

63-
- **`put(url: string, data: any = {}, config: Config = {}): Promise<Response>`**
71+
Performs a `PATCH` request. It takes the same arguments as the axios `patch` method.
6472

65-
Performs a `PUT` request. It takes the same argument as Axios's `put` method.
73+
### `delete`
6674

67-
### patch
75+
- `delete(url: string, config: Config = {}): Promise<Response>`
6876

69-
- **`patch(url: string, data: any = {}, config: Config = {}): Promise<Response>`**
77+
Performs a `DELETE` request. It takes the same arguments as the axios `delete` method.
7078

71-
Performs a `PATCH` request. It takes the same argument as Axios's `patch` method.
79+
### `request`
7280

73-
### delete
81+
- `request(config: Config): Promise<Response>`
7482

75-
- **`delete(url: string, config: Config = {}): Promise<Response>`**
83+
Performs a request with the given config options. Requests will default to `GET` if the `method` option is not specified.
7684

77-
Performs a `DELETE` request. It takes the same argument as Axios's `delete` method.
85+
All request aliases call this method by merging the relevant configs. You may use this method if you are more familiar with using the axios API in favour of alias methods.

docs/api/response.md

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,50 +4,56 @@ sidebarDepth: 2
44

55
# Response
66

7-
The Response object is what gets returned when you make API call via Request object.
7+
API requests return a Response object. This is responsible for carrying and handling the response body and ultimately executing actions such as persisting data to the store.
88

99
## Instance Properties
1010

11-
### response
11+
### `response`
1212

13-
- **`response: AxiosResponse`**
13+
- **Type**: `Object`
1414

15-
Please refer to the [Axios documentation](https://github.com/axios/axios#response-schema) for more details.
15+
The axios response schema. Please refer to the [axios documentation](https://github.com/axios/axios#response-schema) for more details.
1616

17-
### entities
17+
### `entities`
1818

19-
- **`entities: Collections | null`**
19+
- **Type**: `Array | null`
2020

21-
The result of Vuex ORM persistent method.
21+
The return value from the Vuex ORM persist method.
2222

23-
### isSaved
23+
**See also**: [Configurations - save](../guide/configurations.md#save)
2424

25-
- **`isSaved: boolean`**
25+
### `isSaved`
2626

27-
Whether the response data is persisted to the store or not.
27+
- **Type**: `boolean`
2828

29-
### model
29+
Set to `true` when response data has persisted to the store.
3030

31-
- **`model: typeof Model`**
31+
### `model`
3232

33-
The Model class that was attached to the Request instance when making an API call.
33+
- **Type**: `typeof Model`
3434

35-
### config
35+
The model class that initially made the request.
3636

37-
- **`config: Config`**
37+
### `config`
3838

39-
The configuration which was passed to the Request instance.
39+
- **Type**: `Object`
40+
41+
The configuration which was passed to the [Request](request) instance.
4042

4143
## Instance Methods
4244

43-
### save
45+
### `save`
4446

45-
- **`save (): Promise<void>`**
47+
- `save(): Promise<void>`
4648

4749
Save response data to the store.
4850

49-
### delete
51+
**See also**: [Deferring Persistence](../guide/usage.md#deferring-persistence)
52+
53+
### `delete`
54+
55+
- `delete(): Promise<void>`
5056

51-
- **`delete (): Promise<void>`**
57+
Delete record from the store after a request has completed. This method relies on the `delete` option and will throw an error if it is not set.
5258

53-
Delete store record depending on `delete` option. If the `delete` option is not specified at the config, it will throw an error.
59+
**See also**: [Delete Requests](../guide/usage.md#delete-requests)

0 commit comments

Comments
 (0)