Skip to content

Instantly share code, notes, and snippets.

@lloydjatkinson
Created September 25, 2019 20:01
Show Gist options
  • Save lloydjatkinson/19292b4a3589b4f6b435e926c0e97cb7 to your computer and use it in GitHub Desktop.
Save lloydjatkinson/19292b4a3589b4f6b435e926c0e97cb7 to your computer and use it in GitHub Desktop.
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