An API gateway over SaaS?

This one's a little extra. Zuplo is so programmable you can use it in ways you've never considered for a gateway... a gateway over SaaS APIs - like AirTable.

Length: 2 minutes

In this example we use the Event Planning Template.

And here's the code in our request handler

import { ZuploContext, ZuploRequest, environment } from "@zuplo/runtime";

export default async function (request: ZuploRequest, context: ZuploContext) {
  const body = await request.json();

  const data = {
    records: [
      {
        fields: {
          Name: body.name,
          Email: body.email,
        },
      },
    ],
  };

  const response = await fetch(environment.ATTENDEES_URL, {
    method: "POST",
    headers: {
      Authorization: `Bearer ${environment.API_KEY}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify(data),
  });

  if (!response.ok) {
    return new Response("Error calling AirTable!", {
      status: 500,
    });
  }
  return new Response("Success", {
    status: 200,
  });
}

If you'd like to learn about other cool things an API gateway can do, check out our top API gateway features guide.

Questions? Let's chatOPEN DISCORD
0members online

Designed for Developers, Made for the Edge