requestPlatformData

Updated:

Makes HTTP requests through the platform's window.

Description

The requestPlatformData capability provides a means of making HTTP requests through APIs connected by the underlying platform. This allows a platform to provide shared authentication, caching, and session management across all Tecton extensions making requests to a supported platform API. Requests can be made either by specifying direct URL routes or by using a dataType identifier which the platform can map to an appropriate endpoint. The API supports standard HTTP methods, request bodies, query parameters, and FormData uploads when available. requestPlatformData returns a promise containing the response body or throws an error for non-200 series responses.

Signature

tecton.sources.requestPlatformData(requestOptions: PlatformRequestBody): Promise<XMLHttpRequest>;
export type PlatformRequestBody = PlatformDataRequest | PlatformRouteRequest;
export interface PlatformRouteRequest {
    route: string;
    method?: 'POST' | 'PUT' | 'DELETE' | 'GET';
    body?: string | FormData;
}
export interface PlatformDataRequest {
    dataType: string;
    dataId?: string;
    params?: Record<string, string>;
    method?: 'POST' | 'PUT' | 'DELETE' | 'GET';
    body?: string | FormData;
}

Usage

Making a POST request to create a new user via direct route.

tecton.sources.requestPlatformData({
    route: '/user',
    method: 'POST',
    body: JSON.stringify({
        name: "Tecton",
        email: "tecton@q2.com"
    })
}).then((xhr) => {
    // Do something with response
}).catch((xhr) => {
    // Fires for non 200 series responses
});

Making a GET request to fetch account data via dataType.

tecton.sources.requestPlatformData({
    dataType: 'Account',
    dataId: '1234',
    method: 'GET',
}).then((xhr) => {
    // Do something with response
}).catch((xhr) => {
    // Fires for non 200 series responses
});

Parameters

requestOptions.route
requestOptions.dataType
requestOptions.dataId
requestOptions.params
requestOptions.method
requestOptions.body

Release Notes

Tecton
0.7.0

Platform Support

UUX
Config
Console