Fetching
Fetching data
Once you have your base request ready (defined url, models, interceptors, etc.) you can call the fetch
method. This method can receive four optional arguments:
fetch(
params?: TParams | null,
queryParams?: Record<string, string | Array<string> | object> | null,
body?: any,
bodyType?: BodyType,
): Promise<Response<TModel>>;
params
- An object containing all variables we want to use in the process of building the request URLqueryParams
- The values we want to add as query params to the request URLbody
- The value that will be sent as a request body - only available in some request methods (e.g.POST
orPUT
)bodyType
- The type of the body payload. This will be automatically determined based on the body value, but it can be overridden here.