Skip to content

Instantly share code, notes, and snippets.

@FabricioFFC
Created July 1, 2018 23:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FabricioFFC/8c02a95a8d63f92df09d40865b4b2ac0 to your computer and use it in GitHub Desktop.
Save FabricioFFC/8c02a95a8d63f92df09d40865b4b2ac0 to your computer and use it in GitHub Desktop.
const teamsApiUrl = 'http://private-c09d5b-worldcup20181.apiary-mock.com/teams';
async function getAll() {
try {
const response = await fetch(teamsApiUrl);
const responseJson = await response.json();
return responseJson;
} catch (error) {
console.error(error); /* eslint-disable-line no-console */
return error;
}
}
async function get(teamCode) {
try {
const response = await fetch(`${teamsApiUrl}/${teamCode}`);
const responseJson = await response.json();
return responseJson;
} catch (error) {
console.error(error); /* eslint-disable-line no-console */
return error;
}
}
const teamsApi = {
getAll,
get,
};
export default teamsApi;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment