fpl-api-node
Advanced tools
Comparing version 2.0.0-alpha.9 to 2.0.0
@@ -15,2 +15,4 @@ "use strict"; | ||
resolve(data); | ||
}).catch(function (e) { | ||
reject(e); | ||
}); | ||
@@ -17,0 +19,0 @@ } |
import * as types from './types'; | ||
export declare function getEntry(entryId: number): Promise<types.Entry>; | ||
export declare function getEntryHistory(entryId: number): Promise<types.EntryRoot>; | ||
@@ -3,0 +4,0 @@ export declare function getEntryEvent(entryId: number, eventNumber: number): Promise<types.EntryEventRoot>; |
@@ -6,2 +6,7 @@ "use strict"; | ||
axios_1.default.defaults.baseURL = 'https://fantasy.premierleague.com/drf'; | ||
axios_1.default.defaults.timeout = 5000; | ||
function getEntry(entryId) { | ||
return getData("/entry/" + entryId); | ||
} | ||
exports.getEntry = getEntry; | ||
function getEntryHistory(entryId) { | ||
@@ -50,7 +55,10 @@ return getData("/entry/" + entryId + "/history"); | ||
return axios_1.default.get(path).then(function (response) { | ||
if (typeof response.data !== 'object') { | ||
throw new Error('fplapi: unable to retrieve data from fpl - the game is most likely being updated'); | ||
} | ||
return response.data; | ||
}).catch(function (error) { | ||
return error; | ||
}).catch(function () { | ||
throw new Error('fplapi: did not receive a response from fpl - incorrect params were most likely provided'); | ||
}); | ||
}); | ||
} |
@@ -8,2 +8,4 @@ "use strict"; | ||
resolve(data.entry); | ||
}).catch(function (e) { | ||
reject(e); | ||
}); | ||
@@ -17,2 +19,4 @@ }); | ||
resolve(data.entry_history); | ||
}).catch(function (e) { | ||
reject(e); | ||
}); | ||
@@ -26,2 +30,4 @@ }); | ||
resolve(data.history); | ||
}).catch(function (e) { | ||
reject(e); | ||
}); | ||
@@ -35,2 +41,4 @@ }); | ||
resolve(data.picks); | ||
}).catch(function (e) { | ||
reject(e); | ||
}); | ||
@@ -44,2 +52,4 @@ }); | ||
resolve(data.history); | ||
}).catch(function (e) { | ||
reject(e); | ||
}); | ||
@@ -53,2 +63,4 @@ }); | ||
resolve(data.elements); | ||
}).catch(function (e) { | ||
reject(e); | ||
}); | ||
@@ -65,2 +77,4 @@ }); | ||
resolve(match); | ||
}).catch(function (e) { | ||
reject(e); | ||
}); | ||
@@ -74,2 +88,4 @@ }); | ||
resolve(data.elements[playerId].stats); | ||
}).catch(function (e) { | ||
reject(e); | ||
}); | ||
@@ -83,2 +99,4 @@ }); | ||
resolve(data.events); | ||
}).catch(function (e) { | ||
reject(e); | ||
}); | ||
@@ -95,2 +113,4 @@ }); | ||
resolve(match); | ||
}).catch(function (e) { | ||
reject(e); | ||
}); | ||
@@ -107,2 +127,4 @@ }); | ||
resolve(playerStatsMap); | ||
}).catch(function (e) { | ||
reject(e); | ||
}); | ||
@@ -116,2 +138,4 @@ }); | ||
resolve(data.teams); | ||
}).catch(function (e) { | ||
reject(e); | ||
}); | ||
@@ -128,2 +152,4 @@ }); | ||
resolve(match); | ||
}).catch(function (e) { | ||
reject(e); | ||
}); | ||
@@ -137,2 +163,4 @@ }); | ||
resolve(data.league); | ||
}).catch(function (e) { | ||
reject(e); | ||
}); | ||
@@ -146,2 +174,4 @@ }); | ||
resolve(data.standings.results); | ||
}).catch(function (e) { | ||
reject(e); | ||
}); | ||
@@ -155,2 +185,4 @@ }); | ||
resolve(data['total-players']); | ||
}).catch(function (e) { | ||
reject(e); | ||
}); | ||
@@ -167,2 +199,4 @@ }); | ||
resolve(match); | ||
}).catch(function (e) { | ||
reject(e); | ||
}); | ||
@@ -169,0 +203,0 @@ }); |
{ | ||
"name": "fpl-api-node", | ||
"version": "2.0.0-alpha.9", | ||
"version": "2.0.0", | ||
"description": "A node wrapper for the Fantasy Premier League (fantasy.premierleague.com) restful web api", | ||
@@ -13,3 +13,3 @@ "main": "dist/index.js", | ||
"lint": "tslint --project tsconfig.json", | ||
"test": "mocha -r ts-node/register test/specs.ts --timeout 15000 --slow 0", | ||
"test": "mocha -r ts-node/register test/specs.ts --timeout 5000 --slow 0", | ||
"prepare": "rm -rf dist && tsc -p src/tsconfig.json", | ||
@@ -16,0 +16,0 @@ "prepublishOnly": "npm run prepare && npm run lint && npm run test" |
@@ -15,6 +15,6 @@ # fpl-api-node | ||
## Usage | ||
## Getting started | ||
```js | ||
import * as fplapi from 'fpl-api-node'; | ||
const fplapi = require('fpl-api-node'); | ||
@@ -27,3 +27,3 @@ fplapi.findEntry(entryId).then((data) => console.log(data)); | ||
Please refer to the [Wiki for API docs](https://github.com/tgreyuk/fpl-api-node/wiki). | ||
Please refer to the [Wiki for API doc and available methods](https://github.com/tgreyuk/fpl-api-node/wiki). | ||
@@ -36,9 +36,10 @@ ## Other | ||
### Caching | ||
```js | ||
import * as fplapi from 'fpl-api-node'; | ||
There is in-built request caching currently set to 2 hours but looking at options to make this more intelligent. | ||
``` | ||
### Caching | ||
There is in-built http request caching currently set to 2 hours but looking at options to make this more intelligent / configurable. | ||
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
25371
741
1
43
1