Cloudflare Docs
Edit this page on GitHub
Set theme to dark (⇧+D)


The Fetch API provides an interface for asynchronously fetching resources via HTTP requests inside of a Worker.

​​ Syntax

export default {
async scheduled(event, env, ctx) {
return await fetch("", {
headers: {
"X-Source": "Cloudflare-Workers",
addEventListener('fetch', event => {
// NOTE: can’t use fetch here, as we’re not in an async scope yet
async function eventHandler(event) {
// fetch can be awaited here since `event.respondWith()` waits for the Promise it receives to settle
const resp = await fetch(event.request);
return resp;
  • fetch(resource, options optional) : Promise<Response>

    • Fetch returns a promise to a Response.

​​ Parameters