Skip to content

Instantly share code, notes, and snippets.

@thiagocordeiro

thiagocordeiro/request.js

Last active Aug 20, 2019
Embed
What would you like to do?
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
You can’t perform that action at this time.