Skip to main content

APIs

APIs provide a flexible way to call the V2 APIs connector. For ways to create V2 APIs, refer to the documentation.

Note

v3 version uses the open capability of HTTP API when calling general APIs.


API Usage Reference

interface apis {
[apisLabel: string]: {
[
method: "request" | "post" | "get" | "head" | "patch" | "delete" | "put"
]: (
callApiOptions: ICallApiOptions,
opts?: IRequestOptions
) => Promise<ResponseObject["data"]>;
};
}

The APIs module supports the following HTTP methods:

Method nameDescriptionSample code
getGET requestapis["apisLabel"].get(callApiOptions)
postPOST requestapis["apisLabel"].post(callApiOptions)
putPUT requestapis["apisLabel"].put(callApiOptions)
deleteDELETE requestapis["apisLabel"].delete(callApiOptions)
headHEAD requestapis["apisLabel"].head(callApiOptions)
patchPATCH requestapis["apisLabel"].patch(callApiOptions)
requestCustom method requestapis["apisLabel"].request(callApiOptions)
Note

apisLabel is the APIs flag, generated when creating a V2 version APIs connector. You can view it in basic information of the connector.

参数

callApiOptions
ICallApiOptions
opts
IRequestOptions

Request object parameter, does not need to pass in, includes url, method, headers, body, as a supplement to customization needs, will override parameters with the same name in callApiOptions

返回

res
ResponseObject['data']

data content in the API response

示例

Call the methodLabel method of the connector named "apisLabel" APIs with a POST call
async function getUserProfile(userId: string) {
try {
const result = await apis["apisLabel"].post({
path: "methodLabel",
body: { userId },
});
console.log("Call success:", result);
return result;
} catch (error) {
console.error("call failed:", error);
throw error;
}
}

// Call the methodLabel method of the connector named "apisLabel" APIs using a GET call
async function getProductList(category: string) {
try {
const result = await apis["apisLabel"].get({
path: "methodLabel",
body: { category },
});
return result;
} catch (error) {
console.error("call failed:", error);
throw error;
}
}