Last active
July 1, 2018 23:31
-
-
Save FabricioFFC/ed32f22eeb071a3d150c1dfca68cc3e5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function get(url) { | |
try { | |
const response = await fetch(url); | |
const responseJson = await response.json(); | |
return responseJson; | |
} catch (error) { | |
console.error(error); /* eslint-disable-line no-console */ | |
return error; | |
} | |
} | |
const httpRequest = { | |
get, | |
}; | |
export default httpRequest; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import httpRequest from '../services/httpRequest'; | |
const teamsApiUrl = 'http://private-c09d5b-worldcup20181.apiary-mock.com/teams'; | |
function getAll() { | |
return httpRequest.get(teamsApiUrl); | |
} | |
function get(teamCode) { | |
return httpRequest.get(`${teamsApiUrl}/${teamCode}`); | |
} | |
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