extra-life
Version:
Extra Life API wrapper for JavaScript in the browser and Node.js.
3 lines (2 loc) • 1.43 kB
JavaScript
var extraLife=function(a){"use strict";var t=a=>fetch(a).then(a=>a.json().then(t=>({headers:a.headers,status:a.status,json:t}))).then(({headers:a,status:t,json:s})=>{if(t>=400)return new Error(`Bad Request: ${t}`);const e=a.get("num-records");return null!==e?{totalRecords:parseInt(e),records:s}:s}).catch(a=>a);const s="https://www.extra-life.org/api",e=(a,t)=>{const s=parseInt(a),e=parseInt(t);return`?limit=${a=s||100}&offset=${1===(t=e||1||1)?1:a*(t-1)}`};return a.getParticipant=async a=>await t(`${s}/participants/${a}`),a.getParticipantActivity=async a=>await t(`${s}/participants/${a}/activity`),a.getParticipantBadges=async a=>await t(`${s}/participants/${a}/badges`),a.getParticipantDonations=async(a,i,n)=>await t(`${s}/participants/${a}/donations${e(i,n)}`),a.getParticipantDonors=async(a,i,n)=>await t(`${s}/participants/${a}/donors${e(i,n)}`),a.getParticipants=async(a,i)=>await t(`${s}/participants${e(a,i)}`),a.getTeam=async a=>await t(`${s}/teams/${a}`),a.getTeamActivity=async a=>await t(`${s}/teams/${a}/activity`),a.getTeamBadges=async a=>await t(`${s}/teams/${a}/badges`),a.getTeamDonations=async(a,i,n)=>await t(`${s}/teams/${a}/donations${e(i,n)}`),a.getTeamDonors=async(a,i,n)=>await t(`${s}/teams/${a}/donors${e(i,n)}`),a.getTeamParticipants=async(a,i,n)=>await t(`${s}/teams/${a}/participants${e(i,n)}`),a.getTeams=async(a,i)=>await t(`${s}/teams${e(a,i)}`),a}({});
//# sourceMappingURL=extra-life.js.map