axios.get('/api/xyz/abcd')
.catch(function (error) {
if (error.response) {
// Request made and server responded
console.log(error.response.data);
console.log(error.response.status);
console.log(error.response.headers);
} else if (error.request) {
// The request was made but no response was received
console.log(error.request);
} else {
// Something happened in setting up the request that triggered an Error
console.log('Error', error.message);
}
});
// WHEN WORKING WITH LOCALHOST
/* The thing is, that iOS is running in a simulator and Android is running in an emulator.
The localhost is pointing to the environment in which the code is running.
The emulator emulates a real device while the simulator is only imitating the device.
Therefore the localhost on Android is pointing to the emulated Android device.
And not to the machine on which your server is running.
The solution is to replace localhost with the IP address of your machine. */
// WORKING WITH WEB API
// add http or https to your url
// ex: www.themealdb.... -> https://www.themealdb....