expFetch
method is part of the Http
class in the experro-storefront
module. It provides an easy way to make HTTP requests with support for SSR (Server-Side Rendering) and customizable headers, request bodies, and methods.
ExpHttpRequest
with the following fields:
Parameter | Type | Description | Required |
---|---|---|---|
key | string | A unique identifier for the request. This is required when enabling SSR (Server-Side Rendering). Ensures correct tracking. | Optional (Required for SSR) |
url | string | The URL of the endpoint you are making the request to. | Required |
enableSSR | boolean | A flag to enable SSR. Set this to true to enable SSR functionality. | Optional |
headers | object | The headers to be sent with the request. If not provided, default headers { 'content-type': 'application/json' } will be used. | Optional |
body | object | The request body, used only for methods like POST , PUT , PATCH , and DELETE . Not required for GET requests. | Optional |
method | GET , POST , PUT , DELETE , `PATCH“ | The HTTP method to be used for the request. This is a required field. | Required |
GET
request without enabling SSR.
POST
request with a request body and enable SSR by setting the enableSSR flag to true. The key must be unique to properly enable SSR.
{ 'content-type': 'application/json' }
expFetch
method is a flexible and efficient way to make HTTP requests, with support for SSR, custom headers, and various HTTP methods. By providing an easy-to-use interface, it simplifies API calls in your application, allowing you to focus on the core logic while handling request details seamlessly.