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: docs/api/model.md
+26-19Lines changed: 26 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,42 +4,49 @@ sidebarDepth: 2
4
4
5
5
# Model
6
6
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.
8
8
9
9
## Static Properties
10
10
11
-
### axios
11
+
### `axios`
12
12
13
-
-**`static axios: AxiosInstance | null`**
13
+
-**Type**: `AxiosInstance | null`
14
14
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.
16
16
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`
18
18
19
-
### globalApiConfig
19
+
-**Type**: `Object`
20
+
-**Default**: `{}`
20
21
21
-
-**`globalApiConfig: GlobalConfig`**
22
+
The property that holds the model configuration for requests.
22
23
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`
24
25
25
-
-**`apiConfig: Config | null`**
26
+
-**Type**: `Object`
26
27
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.
Return a newly created [Request](request) instance.
34
41
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`
36
43
37
-
### api
44
+
-`setAxios(axios: AxiosInstance): void`
38
45
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.
40
47
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.
Copy file name to clipboardExpand all lines: docs/api/request.md
+38-30Lines changed: 38 additions & 30 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,74 +4,82 @@ sidebarDepth: 2
4
4
5
5
# Request
6
6
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.
8
8
9
9
```js
10
10
constrequest=User.api()
11
11
```
12
12
13
-
Usually, you could just call Request methods directly by method chaining.
13
+
You can call request methods directly through chaining.
14
14
15
15
```js
16
-
User.api().get()
16
+
constresponse=User.api().get()
17
17
```
18
18
19
19
## Constructor
20
20
21
-
-**``constructor(model: typeof Model)``**
21
+
-`constructor(model: typeof Model)`
22
22
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.
24
26
25
27
```js
26
-
// This is equivalent to...
27
-
constrequest=newRequest(User)
28
+
import { Request } from'@vuex-orm/plugin-axios'
28
29
29
-
// This.
30
-
constrequest=User.api()
30
+
constrequest=newRequest(User)
31
31
```
32
32
33
33
## Instance Properties
34
34
35
-
### model
35
+
### `model`
36
36
37
-
-**`model: typeof Model`**
37
+
-**Type**: `typeof Model`
38
38
39
-
The Model class that is attached to the Request instance.
39
+
The model class that is attached to the Request instance.
40
40
41
-
### axios
41
+
### `axios`
42
42
43
-
-**`axios: AxiosInstance`**
43
+
-**Type**: `AxiosInstance`
44
44
45
-
The Axios instance that will be used to perform the request.
45
+
The axios instance that will be used to perform the request.
Performs a request with the given config options. Requests will default to `GET` if the `method` option is not specified.
76
84
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.
Copy file name to clipboardExpand all lines: docs/api/response.md
+27-21Lines changed: 27 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,50 +4,56 @@ sidebarDepth: 2
4
4
5
5
# Response
6
6
7
-
The Response objectis 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.
8
8
9
9
## Instance Properties
10
10
11
-
### response
11
+
### `response`
12
12
13
-
-**`response: AxiosResponse`**
13
+
-**Type**: `Object`
14
14
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.
16
16
17
-
### entities
17
+
### `entities`
18
18
19
-
-**`entities: Collections | null`**
19
+
-**Type**: `Array | null`
20
20
21
-
The result of Vuex ORM persistent method.
21
+
The return value from the Vuex ORM persist method.
0 commit comments