Skip to content

Latest commit

 

History

History
37 lines (25 loc) · 1.34 KB

File metadata and controls

37 lines (25 loc) · 1.34 KB

Netlify examples

Proxy requests to another source

You can use fetch() to make requests to other sources via an Edge Function.

Code example

Edge Functions are files held in the netlify/edge-functions directory.

import { Context } from "https://edge.netlify.com";

export default async (request: Request, context: Context) => {
  const joke = await fetch("https://icanhazdadjoke.com/", {
    headers: {
      Accept: "application/json",
    },
  });
  const jsonData = await joke.json();
  return context.json(jsonData);
};

View this example on the web

Deploy to Netlify

You can deploy this and all the other examples in this repo as a site of your own to explore and experiment with, by clicking this button.

Deploy to Netlify