epl-fixtures
Version:
Fixtures for Premier League clubs
22 lines (19 loc) • 686 B
JavaScript
;
const got = require('got');
const htmlParser = require('./htmlParser');
const cache = require('./cache');
module.exports = function (allOrClubId, callback) {
if (cache.isCached(allOrClubId)) {
cache.loadFromCache(allOrClubId, callback);
} else {
got('http://www.premierleague.com/en-gb/matchday/matches.html?paramClubId=' + allOrClubId + '¶mComp_8=true' +
'¶mComp_1=true¶mComp_2=true¶mComp_5=true¶mComp_6=true&view=.dateSeason')
.then(response => {
htmlParser(response.body, callback);
cache.saveToCache(response.body, allOrClubId);
})
.catch(error => {
callback(true, []);
});
}
}