An API gateway over SaaS?

Length: 2 minutes

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.

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,
  });
}

Designed for Developers, Made for the Edge