Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in miliseconds.
import { fetchWorker } from "https://esm.town/v/postpostscript/fetchWorker";
using worker = await fetchWorker({
url: "https://esm.town/v/postpostscript/fetchWorkerExample",
handler: "handler",
});
const res = await worker.fetch("/", {
method: "POST",
body: JSON.stringify({
test: 1,
}),
headers: {
"Content-Type": "application/json",
},
});
console.log(await res.json());
// {
// method: "POST",
// url: "https://7ae81ab0-04cf-485a-ae09-054c4d3be6b3.val.town/",
// text: { test: 1 },
// headers: { "content-type": "application/json" }
// }
url
(string
, required): URL that the worker will fetch the handler fromhandler
(string
, defaults todefault
): name of export that will execute the request
Migrated from folder: Worker/fetchWorker