axios.get('https://jsonplaceholder.typicode.com/invalid-url')
.then(response => {
console.log('Data:', response.data);
})
.catch(error => {
if (error.response) {
console.error('Error Response:', error.response.data);
} else if (error.request) {
console.error('No Response:', error.request);
} else {
console.error('Error:', error.message);
}
});
If you're making multiple requests to the same base URL or with the same configuration, you can create an Axios instance.