Last active
August 20, 2019 07:25
-
-
Save thiagocordeiro/2a570eb8586473767482d29d5e62e4c7 to your computer and use it in GitHub Desktop.
Axios HTTP Client
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
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