Skip to content

Instantly share code, notes, and snippets.

@thiagocordeiro
Last active August 20, 2019 07:25
Show Gist options
  • Save thiagocordeiro/2a570eb8586473767482d29d5e62e4c7 to your computer and use it in GitHub Desktop.
Save thiagocordeiro/2a570eb8586473767482d29d5e62e4c7 to your computer and use it in GitHub Desktop.
Axios HTTP Client
const axios = require('axios');
axios.get('/users/12345')
.then(function (response) {
const statusCode = response.status;
// successful request/response
})
.catch(function (error) {
const statusCode = error.response.status;
if (statusCode < 500) {
// client error
return;
}
// server error
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment