REST

Send REST requests with the REST built-in.

Request

Perform a request against a REST resource.
FieldTypeDefaultDescription
restResourcestringRequiredThe alias of the REST resource.
method"GET" | "POST" | "PUT" | "PATCH" | "DELETE"RequiredThe REST API method.
pathstring""Optional path to append to the base URL configured in the REST resource.
bodyobject nullOptional request body.
bodyType"json" | "raw" | "form-data" | "x-www-form-urlencoded"""Optional body content type.
headersobjectnullOptional object containing request headers.
formDataobjectnullOptional form data.
urlParamsobjectnullOptional object containing urlParams.
retryFailuresbooleanfalseTrue to retry the request on 500, 502, 503, and 504 error codes. Requests will always be retried on 408 and 429 error codes.

Usage

javascript
Copied
1
import airplane from "airplane";
2
3
export default airplane.task(
4
{
5
slug: "get_user_profiles",
6
resources: ["profile_api"],
7
},
8
async (params) => {
9
const run = await airplane.rest.request(
10
"profile_api", // The slug of the REST resource to query.
11
"GET", // The REST method to execute.
12
"/profile" // The URL path.
13
);
14
return run.response;
15
}
16
);