export interface RequestConfig { /** * A BodyInit object or null to set request's body. */ body?: BodyInit | null; /** * A string indicating how the request will interact with the browser's cache to set request's cache. */ cache?: RequestCache; /** * A string indicating whether credentials will be sent with the request always, never, or only when sent to a same-origin URL. Sets request's credentials. */ credentials?: RequestCredentials; /** * A Headers object, an object literal, or an array of two-item arrays to set request's headers. */ headers?: HeadersInit; /** * A cryptographic hash of the resource to be fetched by request. Sets request's integrity. */ integrity?: string; /** * A boolean to set request's keepalive. */ keepalive?: boolean; /** * A string to set request's method. */ method?: string; /** * A string to indicate whether the request will use CORS, or will be restricted to same-origin URLs. Sets request's mode. */ mode?: RequestMode; /** * A string indicating whether request follows redirects, results in an error upon encountering a redirect, or returns the redirect (in an opaque fashion). Sets request's redirect. */ redirect?: RequestRedirect; /** * A string whose value is a same-origin URL, "about:client", or the empty string, to set request's referrer. */ referrer?: string; /** * A referrer policy to set request's referrerPolicy. */ referrerPolicy?: ReferrerPolicy; /** * An AbortSignal to set request's signal. */ signal?: AbortSignal | null; /** * Can only be null. Used to disassociate request from any Window. */ window?: unknown; } declare type RequestInfo = Request | string; export declare class Fetch { /** * Request Method. use this method in case you need to send a request with specific configurarions. * * @param {Request|string} req - it can be a string or a request. * @param {object} config - Request config obj. * @returns {Promise} promise with yow response. * @example * const api = new Fetch(); * api.request("https://www.mi-pagina-web.com/api/un-path",{ * cache: "default", * mode:"CORS", * method:"put", * headers: { * "Content-Type": "application/json", * "Accept": "application/json", * } * }) */ request: (req: RequestInfo, config: RequestConfig) => Promise; /** * The HTTP GET method requests a representation of the specified resource. * Requests using GET should only be used to request data (they shouldn't incude data). * * If you need to send a token on each request, you need to pass a second parameter with yow headers. * @param {string} url - endpont. * @param {HeaderInit} [headers] - HTTP Headers. * @returns {Promise} promise with yow response. * @example * const api = new Fetch(); * api.get("www.domain.com"); * // or * api.get("www.domain.com", { * "Content-Type": "application/json", * "Accept": "application/json", * "Authorization":"Bearer I_am_yow_token" * }) */ get: (url: string, headers?: HeadersInit) => Promise; /** * The HTTP DELETE request method deletes the specified resource. * * If you need to send a token on each request, you need to pass a second parameter with yow headers. * @template R - response object. * @param {string} url - endpont. * @param {HeaderInit} [headers] - HTTP Headers. * @returns the status code of the request. * @example * const api = new Fetch(); * api.delete("www.domain.com"); * // or * api.delete("www.domain.com", { * "Content-Type": "application/json", * "Accept": "application/json", * "Authorization":"Bearer I_am_yow_token" * }) */ delete: (url: string, headers?: HeadersInit) => Promise; /** * The HTTP POST method sends data to the server. The type of the body of the request is indicated by the Content-Type header. * The difference between PUT and POST is that PUT is idempotent: calling it once or several times successively has the same effect (that is no side effect), where successive identical POST may have additional effects, like passing an order several times. * A POST request is typically sent via an HTML form and results in a change on the server. In this case, the content type is selected by putting the adequate string in the enctype attribute of the
element or the formenctype attribute of the or