How to catch and handle Vue axios error?

Most website service crashes are caused by network errors. Therefore, it is very important to reasonably catch network errors and notify the user and website maintenance personnel. This post will introduce: ① How to catch Vue axios error? ② How to notify the user that an error has occurred? ③ How to notify website maintenance personnel that an error has occurred?

Keywords: website , network request , Vue , axios , catch error.

Notify user

Using .catch() can easily catch error when Vue axios execute network requests. After catching the error, we should notify the user by printing the error time, the interface of the error report, and provide the user with a feedback channel, prompting the user to contact the website maintenance staff. In order to avoid further crashes of the website, an empty return value needs to be given after catching the error.

alert error infomation and break the operation

Notify maintenance personnel

In addition to prompting the user with the error message, it is more important to notify the maintainer of the website of the error so that the website can be quickly fixed. One of the good way is to post another service port to report the error. The message should also be the error time, interface, error detailed.

The crash of the website service is inevitable. If the request execute by Vue axios, you can use .catch() to catch the error. After that, you need to explain the reason for the error, the way to leave feedback, and prompt the user for feedback. These practices can improve the user’s experience. At the same time, website maintainers should be notified through other services port as much as possible. There is a case of Python Flask alerting website maintainers via email, welcome to the related articles.

Edit Template

Leave a Reply

Your email address will not be published. Required fields are marked *

Chaoxu Wei

Master student at Tongji University (Writer & Blogger)

Job hunting, both part-time and full-time jobs are accepted. Job recommendation please email me weichaoxu1998@gmail.com, thank you very much!

0
0
Edit Template

“There are many people in the world who want to work hard but can’t, and people who work too hard and are exhausted. Please don’t use your efforts only to chase your own victory, please use them to help others.”

Follow

Contact

libertynlp@163.com

+86-18385537403

Yangpu District, Shanghai