hg-pyun / axios-logger

Beautify Axios Logging Messages
MIT License
173 stars 33 forks source link

Error logger crashes if config is null or undefined #94

Closed cernadasjuan closed 2 years ago

cernadasjuan commented 3 years ago

Hi! Sometimes the axios error comes with config null or undefined, and the errorLogger crashes with this exception

ERROR: Cannot destructure property `method` of 'undefined' or 'null'.

As a workaround I resolved it by adding this validation in the axios interceptor

axiosInstance.interceptors.response.use(responseLogger, (error) => {
  if (error.config && error.response) {
    return errorLogger(error)
  }
  return Promise.reject(error)
})

But I think the best solution is to add a validation in the errorLogger to prevent this type of crashes (if I catch some free time I can solve this and create the PR).

Thanks!

Note: I think is related with this issue #50

hg-pyun commented 3 years ago

Thank you for feedback. I will consider 🙇