Socket
Socket
Sign inDemoInstall

@shopware/api-client

Package Overview
Dependencies
Maintainers
0
Versions
418
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@shopware/api-client - npm Package Compare versions

Comparing version 0.0.0-canary-20240620152349 to 0.0.0-canary-20240620182540

4

package.json
{
"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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc