-
-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: incresed tsdoc documentation a lot
- Loading branch information
1 parent
384c6b5
commit d6b41e8
Showing
12 changed files
with
297 additions
and
176 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,35 @@ | ||
# Response object | ||
|
||
Every response that came from our custom axios instance will have some extras properties. | ||
Axios cache interceptor returns a slightly changed than the original axios response. | ||
Containing information about the cache and other needed properties. | ||
|
||
```ts | ||
const response = await axios.get('https://jsonplaceholder.typicode.com/posts/1'); | ||
## id | ||
|
||
// response.data | ||
// response.cached | ||
// response.id | ||
// ... | ||
``` | ||
- Type: `string` | ||
|
||
Every response that came from our custom axios instance, will have some extras properties, | ||
that you can retrieve like that: | ||
The [Request ID](../guide/request-id.md) used in this request. | ||
|
||
It may have been generated by the [Key Generator](../guide/request-id.md#custom-generator) | ||
or a custom one provided by [`config.id`](./request-specifics.md#id) | ||
|
||
```ts | ||
const result = await cache.get(/* ... */); | ||
const id = result['propertyName']; | ||
const response = await axios.get('url', { id: 'my-overridden-id' }); | ||
|
||
// This request used 'my-overridden-id' and | ||
// not the one generated by the key generator | ||
response.id === 'my-overridden-id'; | ||
``` | ||
|
||
## `cached` | ||
## cached | ||
|
||
- Type: `boolean` | ||
|
||
A simple boolean that tells you if this request came from the cache or through the | ||
network. | ||
A simple boolean indicating if the request returned data from the cache or from the | ||
network call. | ||
|
||
::: tip | ||
|
||
This is not a boolean to check wether this request is capable of being cached or not. | ||
This does not indicated if the request was capable of being cached or not, as options like | ||
[`cache.override`](./request-specifics.md#cache-override) may have been enabled. | ||
|
||
::: | ||
|
||
## `id` | ||
|
||
- Type: `string` | ||
|
||
The resolved [request id](../guide/request-id.md). This property represents the ID used | ||
throughout the internal code. | ||
|
||
Depending on the [Key Generator](../guide/request-id.md#custom-generator), it can differ | ||
from provided example on the [Request Id](../guide/request-id.md). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.