fetch(requestOptions: IRequestOptions): IRequesterFetchItem¶
The fetch method is used to make HTTP requests.
Input parameters¶
requestOptions¶
IRequestOptions
options for the request (IRequestOptions).
Returned value¶
The IRequesterFetchItem object.
Example¶
useStorefront(async (storefront) => {
const httpRequesterApi = storefront.getApiSync('HTTPRequesterApi');
const requestOptions = {
url: 'https://example.com/webapi/front/pl_PL/products/PLN/16',
method: 'get',
repeatOptions: {
maxAttempts: 5,
attemptDelayInMs: 300
},
cacheOptions: {
type: 'memory',
ttlInMs: 300000
}
};
const fetchItem = httpRequesterApi.fetch(requestOptions);
const response = await fetchItem.response;
const product = response.data;
});