Skip to content
  • Workflows
  • Bindings

kinde.secureFetch

The kinde.secureFetch binding allows you to make POST requests to external APIs where the payload is encrypted with the workflow encryption key you have previously set up in Kinde.

Available in workflows

Link to this section
export const workflowSettings = {
// ...other settings
bindings: {"kinde.secureFetch": {}}
};
Link to this section

The Kinde infrastructure library provides type-safe secure fetch requests:

Note: you will also need the url binding enabled for the workflow as this is used under the hood.

import {fetch} from "@kinde-oss/infrastructure";
export default async function Workflow(event) {
const {data} = await secureFetch(`https://api.somethingsecret.com/api`, {
method: "POST",
responseFormat: "json",
headers: {"Content-Type": "application/json"}
});
console.log(data);
}

Using the low-level API

Link to this section

If you’re not using the infrastructure library, you can call the underlying API directly:

const res = await kinde.secureFetch(`https://ipinfo.io/${event.request.ip}`, {
method: "POST",
responseFormat: "json",
headers: {"Content-Type": "application/json"}
});
const {json} = res;
console.log(json);