Created
September 25, 2019 20:01
-
-
Save lloydjatkinson/19292b4a3589b4f6b435e926c0e97cb7 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
import axios from 'axios'; | |
const rocketEndpoint = 'https://api.spacexdata.com/v3/rockets'; | |
const upcomingLaunchesEndpoint = 'https://api.spacexdata.com/v3/launches/upcoming'; | |
const getRockets = async () => { | |
try { | |
return { | |
success: true, | |
data: (await axios.get(rocketEndpoint)).data | |
}; | |
} catch (error) { | |
return { | |
success: false, | |
error | |
}; | |
} | |
}; | |
const getUpcomingLaunches = async () => { | |
try { | |
return { | |
success: true, | |
data: (await axios.get(upcomingLaunchesEndpoint)).data | |
}; | |
} catch (error) { | |
return { | |
success: false, | |
error | |
}; | |
} | |
}; | |
export { | |
getRockets, | |
getUpcomingLaunches | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment