Create a new Wraker instance
Optional
URL of the worker script
Worker options
Wraker instance
const instance = new Wraker(new URL("worker.js", import.meta.url), { type: "module",}); Copy
const instance = new Wraker(new URL("worker.js", import.meta.url), { type: "module",});
Fetch data from the worker
Path to fetch
Fetch options
Promise
const data = await instance.fetch("/hello");console.log(data.body); // Hello, world! Copy
const data = await instance.fetch("/hello");console.log(data.body); // Hello, world!
Static
Initialize a Wraker instance from an existing Worker
Worker instance
const worker = new Worker("worker.js");const instance = Wraker.fromWorker(worker); Copy
const worker = new Worker("worker.js");const instance = Wraker.fromWorker(worker);
Create a new Wraker instance