js-smart-request-cache
v2.2.0
Published
a small wrapper for fetch
Downloads
2
Readme
js-smart-request-cache
RequestHelper
Signature:
class RequestHelper {
static timeToExpireInMilliseconds: number; // the time (milliseconds) it takes to invalidate the cached value.
static GET(url: string, fetchOptions?: object, forceRequest?: boolean, responseType?: RequestResponseType, acceptableStatusCodes?: number[]): Promise<any>;
}
Example:
RequestHelper.timeToExpireInMilliseconds = 10000;
RequestHelper.GET("https://example.com/api/orders?id=1", {
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
},
false,
RequestResponseType.Json,
[200, 201]
})
.then((response) => {
// Handle Response ...
})
.catch((e) => {
// Handle Error ...
});