Web APIs
Integrations communicate with the outside world over HTTP. Your integration can send async HTTP requests through HTTP Fetch. See the MDN docs to learn more.
Example:
const resp = await fetch(
`https://example.com/api/endpoint`,
{
headers: {
Authorization: `<example-auth>`,
Accept: 'application/json',
},
}
);
Example:
const handleFetchEvent = async (request, context) => {
return new Response({message: "Hello World"});
};
Example:
const request = new Request("https://example.com", {
method: "POST",
body: '{"message": "Hello World"}',
});
Example:
// Base URLs:
let baseUrl = "https://gitbook.com/";
let integrations = new URL("/integrations", baseUrl);
// => 'https://gitbook.com/integrations'
The
URLSearchParams
interface defines utility methods to work with the query string of a URL. See the MDN docs to learn more.Last modified 4mo ago