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/template";
import { fetch } from "@kksh/api/ui/custom";
import { fetch } from "@kksh/api/headless";
await fetch('https://schema.kunkun.sh') .then((res) => res.json()) .then((data) => {});
Sample package.json
permission configuration:
..."permissions": ["fetch:all"],...