Skip to content
Kunkun

Fetch

Docs: https://docs.api.kunkun.sh/interfaces/index.IFetch

When you use the built-in fetch or http client like Axios directly in iframe or web worker, you may encounter CORS issue.

fetch() API provided in @kksh/api sends the request through the host app, thus bypassing CORS.

'fetch:all' permission is required to use this API.

import { fetch } from "@kksh/api/ui/worker";
await fetch('https://schema.kunkun.sh')
.then((res) => res.json())
.then((data) => {});

Sample package.json permission configuration:

package.json
...
"permissions": ["fetch:all"],
...