Skip to main content

dwebServiceWorker.externalFetch()

BFChainPlugindwebServiceWorkerexternalFetchLess than 1 minute

Method for communicating with other apps. Pass the MMID as the first parameter to declare who to communicate with.

The second and third parameters are both used to construct the request.

externalFetch generally works in conjunction with the fetch event, with the former sending messages and the latter receiving messages. See fetchEvent for details

Example

import { dwebServiceWorker } from "@plaoc/plugins";

const base = new URL(document.baseURI);
const url = new URL("/say/hi", base.origin);
url.searchParams.set("message", "hi");

const res = await dwebServiceWorker.externalFetch(
  `game.dweb.waterbang.top.dweb`, // Who to communicate with
  url
);

console.log("Received response message => ", await res.text());

Function signature

externalFetch(mmid: $MMID, input: RequestInfo | URL, init?: RequestInit | undefined): Promise<Response>

Parameters

  • mmid

Identifier of other app; The parameter value is a $MMID type object.

Request object of Web API.

type RequestInfo = Request | string;

Return value

Platform compatibility

Attribute/Method/EventAndroidIOSDesktop
externalFetch

dwebServiceWorker

Comments
  • Latest
  • Oldest
  • Hottest
Powered by Waline v2.15.7