Skip to content

Instantly share code, notes, and snippets.

@charlintosh
Last active July 9, 2020 21:31
Show Gist options
  • Save charlintosh/f51dbbd7fb286b44795526264195a857 to your computer and use it in GitHub Desktop.
Save charlintosh/f51dbbd7fb286b44795526264195a857 to your computer and use it in GitHub Desktop.
const axios = require('axios')
const doRequest = () => {
try {
return axios.get('https://thegreatapi.org/v1')
} catch (error) {
console.error(error)
}
}
const callAPI = async () => {
const response = doRequest()
.then(response => {
console.log(response);
console.log("It works!");
})
.catch(error => {
console.log(error)
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment