diff --git a/README.md b/README.md index 2d39982..b22cc48 100644 --- a/README.md +++ b/README.md @@ -56,8 +56,8 @@ axios.get('/user?ID=12345') .then(function (response) { console.log(response); }) - .catch(function (response) { - console.log(response); + .catch(function (error) { + console.log(error); }); // Optionally the request above could also be done as @@ -69,8 +69,8 @@ axios.get('/user', { .then(function (response) { console.log(response); }) - .catch(function (response) { - console.log(response); + .catch(function (error) { + console.log(error); }); ``` @@ -84,8 +84,8 @@ axios.post('/user', { .then(function (response) { console.log(response); }) - .catch(function (response) { - console.log(response); + .catch(function (error) { + console.log(error); }); ``` @@ -414,18 +414,18 @@ instance.interceptors.request.use(function () {/*...*/}); ```js axios.get('/user/12345') - .catch(function (response) { - if (response instanceof Error) { - // Something happened in setting up the request that triggered an Error - console.log('Error', response.message); - } else { + .catch(function (error) { + if (error.response) { // The request was made, but the server responded with a status code // that falls out of the range of 2xx - console.log(response.data); - console.log(response.status); - console.log(response.headers); - console.log(response.config); + console.log(error.response.data); + console.log(error.response.status); + console.log(error.response.headers); + } else { + // Something happened in setting up the request that triggered an Error + console.log('Error', error.message); } + console.log(error.config); }); ``` diff --git a/examples/get/index.html b/examples/get/index.html index b0ab807..dc8e51b 100644 --- a/examples/get/index.html +++ b/examples/get/index.html @@ -20,13 +20,13 @@ '' + person.name + '' + '