OptionalheadersAdditional HTTP headers to include in the request
import {
HttpHeaders,
PlatformServiceName,
} from '@limetech/lime-web-components';
const http = platform.get(PlatformServiceName.Http);
const headers: HttpHeaders = {
Authorization: 'Bearer token123',
'Accept-Language': 'en-US',
};
const data = await http.get('my_addon/endpoint', { headers });
OptionalparamsQuery parameters to append to the URL
Parameters will be URL-encoded and appended to the request URL.
import { HttpParams, PlatformServiceName } from '@limetech/lime-web-components';
const http = platform.get(PlatformServiceName.Http);
const params: HttpParams = {
active: 'true',
role: ['admin', 'user'],
};
// Requests my_addon/users?active=true&role=admin&role=user
const users = await http.get('my_addon/users', { params });
OptionalresponseExpected response data type. Defaults to 'json'
json: Parse response as JSON (default)text: Get response as plain text stringblob: Get response as binary Blob (for file downloads)arraybuffer: Get response as ArrayBuffer (for binary data processing)import { PlatformServiceName } from '@limetech/lime-web-components';
const http = platform.get(PlatformServiceName.Http);
const report: Blob = await http.get('my_addon/report.pdf', {
responseType: 'blob',
});
const url = URL.createObjectURL(report);
window.open(url);
Configuration options for HTTP requests
Example: Set parameters, headers, and response type