UNPKG

epl-fixtures

Version:

Fixtures for Premier League clubs

22 lines (19 loc) 686 B
'use strict'; 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 + '&paramComp_8=true' + '&paramComp_1=true&paramComp_2=true&paramComp_5=true&paramComp_6=true&view=.dateSeason') .then(response => { htmlParser(response.body, callback); cache.saveToCache(response.body, allOrClubId); }) .catch(error => { callback(true, []); }); } }