npm.io
2.2.0 • Published 3 years ago

js-smart-request-cache

Licence
ISC
Version
2.2.0
Deps
0
Size
16 kB
Vulns
0
Weekly
0

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 ...
    });

Keywords