I have a general query about Axios and Promises. Maybe someone can help me clear this concept.
Basic Interceptor of Axios includes:
// Add a response interceptor
axios.interceptors.response.use(function (response) {
// Any status code that lie within the range of 2xx cause this function to trigger
// Do something with response data
return response;
}, function (error) {
// Any status codes that falls outside the range of 2xx cause this function to trigger
// Do something with response error
return Promise.reject(error);
});
My question is what's the difference between returning error as
Project.reject(error);
and as
return error;
This response and error goes to the Request 'then' amd 'catch' blocks respectively I believe. But what's the difference if we use Promise.resolve and Promise.reject?