src/rest_client.js
async function fetchData(key, transformation, cacheMiss) {

    // TODO: needs better caching logic
    var data = cache.get(key);

    if (data) {
        return data;
    }

    try {
        data = transformation(await cacheMiss());
    } catch (err) {
        throw new Error('The response contains invalid data');
    }

    cache.put(key, data);
    return data;
}
async function fetchData(key, transformation, cacheMiss) {

    // TODO: needs better caching logic
    var data = cache.get(key);

    if (data) {
        return data;
    }

    try {
        data = transformation(await cacheMiss());
    } catch (err) {
        throw new Error('The response contains invalid data');
    }

    cache.put(key, data);
    return data;
}
async function fetchData ( key , transformation , cacheMiss ) { // TODO: needs better caching logic var data = cache . get ( key ) ; if ( data ) { return data ; } try { data = transformation ( await cacheMiss ( ) ) ; } catch ( err ) { throw new Error ( 'The response contains invalid data' ) ; } cache . put ( key , data ) ; return data ; }
Tries to fetch the response from the cache and provides fallback if not found

@param {string} key - Key of the data in the cache
@param {function} transformation - Transformation of the data
@param {function} cacheMiss - Handler in case of the data is not found in the cache
@returns {*}
Tries to fetch the response from the cache and provides fallback if not found