function fetchContent()

in public/src/js/modules/content-api.js [26:52]


function fetchContent(apiUrl) {
    return request({
        url: CONST.apiSearchBase + '/' + apiUrl
    }).then(function(resp) {
        if (!resp.response
            || _.intersection(['content', 'editorsPicks', 'results', 'mostViewed'], _.keys(resp.response)).length === 0
            || resp.response.status === 'error') {
            return;
        } else if (resp.response.content) {
            return {
                content: [resp.response.content],
                title: getTagOrSectionTitle(resp.response)
            };
        } else {
            return {
                content: _.chain(['editorsPicks', 'results', 'mostViewed'])
                    .filter(function(key) { return _.isArray(resp.response[key]); })
                    .map(function(key) { return resp.response[key]; })
                    .flatten()
                    .value(),
                title: getTagOrSectionTitle(resp.response)
            };
        }
    })
    // swallow error
    .catch(function () {});
}