Request failed with status code 401 at e.exports (isAxiosError.js:10) at e.exports (isAxiosError.js:10) at XMLHttpRequest.l.onreadystatechange (isAxiosError.js:10) code example

Example 1: get json data when we get error code in axios

axios.post('/formulas/create', {
	name: "",
	parts: ""
})
.then(response => { 
	console.log(response)
})
.catch(error => {
    console.log(error.response)
});

Example 2: axios how to get error response

axios.post('/formulas/create', {
	name: "",
	parts: ""
})
.then(response => { 
	console.log(response)
})
.catch(error => {
    console.log(error.response)
});

Tags:

Misc Example