Class: ApiRequest

@aofl/api-request~ ApiRequest


new ApiRequest()

Creates an instance of ApiRequest.
Source:

Members


<static, readonly> DEFAULT_CACHE_NAMESPACE :String

Type:
  • String
Source:

Methods


addCacheManager(namespace, expire)

Parameters:
Name Type Description
namespace String
expire Number
Source:

addFormatter(format, formatter)

addformatter() adds a new format to formatter's list.
Parameters:
Name Type Description
format String name for the formatter
formatter FormatterManager formatter object
Source:

clearCache(namespace)

Clears cached data by namespace.
Parameters:
Name Type Description
namespace String cache namespace
Source:

getCacheManager(namespace, expire)

Returns an existing cacheManager if it exists or creates a new one and assigns it to the namespace.
Parameters:
Name Type Description
namespace String cache namespace
expire Number
Source:
Returns:
Type
CacheManager

purgeCache(namespace)

Parameters:
Name Type Description
namespace String
Source:

request(url, payload, format, fromCache, namespace)

Makes a network call using fetch API.
Parameters:
Name Type Default Description
url String request url
payload * data
format String formatter name
fromCache Boolean true fetch new data or return cached
namespace String default cache manager namespace
Source:
Returns:
Type
Promise

updateCacheInterval(namespace, expire)

Update a cache managers expire time
Parameters:
Name Type Description
namespace String
expire Number
Source: