@shopware/api-client
Advanced tools
Comparing version 0.0.0-canary-20240620152349 to 0.0.0-canary-20240620182540
{ | ||
"name": "@shopware/api-client", | ||
"version": "0.0.0-canary-20240620152349", | ||
"version": "0.0.0-canary-20240620182540", | ||
"description": "Shopware client for API connection.", | ||
@@ -51,3 +51,3 @@ "author": "Shopware", | ||
"vitest": "1.6.0", | ||
"eslint-config-shopware": "0.0.0-canary-20240620152349", | ||
"eslint-config-shopware": "0.0.0-canary-20240620182540", | ||
"tsconfig": "0.0.0" | ||
@@ -54,0 +54,0 @@ }, |
@@ -38,2 +38,4 @@ # shopware/frontends - api-client | ||
## Store API client setup | ||
Recommended practice is to create a separate module file. For example `src/apiClient.ts`, and import it whenever you need to use API Client. | ||
@@ -157,2 +159,43 @@ | ||
### Fetch features | ||
The new API client is leveraging [ofetch](https://github.com/unjs/ofetch) library, which has built in support for AbortController, timeout and other features. | ||
Example usage of AbortController to cancell your request: | ||
```typescript | ||
const controller = new AbortController(); | ||
const request = client.invoke("readContext get /context", { | ||
fetchOptions: { | ||
signal: controller.signal, | ||
}, | ||
}); | ||
controller.abort(); // At this point client will throw an error with the information, that the request has been cancelled | ||
``` | ||
Other example of using `fetchOptions` for setting the timeout: | ||
```typescript | ||
const request = client.invoke("readContext get /context", { | ||
fetchOptions: { | ||
timeout: 5000, // 5 seconds | ||
}, | ||
}); | ||
``` | ||
All exposed options available under `fetchOptions` are: | ||
- `cache` | ||
- `duplex` | ||
- `keepalive` | ||
- `priority` | ||
- `redirect` | ||
- `retry` | ||
- `retryDelay` | ||
- `retryStatusCodes` | ||
- `signal` | ||
- `timeout` | ||
### Predefining methods | ||
@@ -225,3 +268,3 @@ | ||
### Latest changes: 0.0.0-canary-20240620152349 | ||
### Latest changes: 0.0.0-canary-20240620182540 | ||
@@ -234,2 +277,18 @@ ### Major Changes | ||
- [#1039](https://github.com/shopware/frontends/pull/1039) [`2343012`](https://github.com/shopware/frontends/commit/2343012ad552b06557e6715055b3abc534fa2fae) Thanks [@patzick](https://github.com/patzick)! - We're exposing `fetchOptions` inside params of `invoke` method. You can now use `ofetch` features like `timeout` or `signal` with AbortController | ||
Example for the AbortController: | ||
```ts | ||
const controller = new AbortController(); | ||
const request = client.invoke("readContext get /context", { | ||
fetchOptions: { | ||
signal: controller.signal, | ||
}, | ||
}); | ||
controller.abort(); // At this point client will throw an error with the information, that the request has been cancelled | ||
``` | ||
- [#560](https://github.com/shopware/frontends/pull/560) [`9643e56`](https://github.com/shopware/frontends/commit/9643e56dafba9282b75c12c96b2afb3a4738f86e) Thanks [@patzick](https://github.com/patzick)! - [createAdminAPIClient] ability to pass optional field `credentials` to be used as authentication method before invoking any Admin API endpoint. | ||
@@ -236,0 +295,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
17069447
205877
328