Vue rookie asked axios how to catch request exception.

do you have any better suggestions for writing norms like this?

`
axios

                .post("/au/api/rulereleaseapply/findAllPubTask", {
                     branchCode: userInfor[0].branchCode,
                     userCode: userInfor[0].userCode,
                     busiinfoFive: "11"
                })
                .then(response => {
                    if (response.data.success) {
                      debugger;
                        console.log("=>", response.data);
                        _this.ruleReleaseVertifyData = response.data.entity.items;
                        loading.close();
                    } else {
                        loading.close();
                        this.$message({
                            showClose: true,
                            message: response.data.errorMessage,
                            type: "error"
                        });
                    }
                }).catch(response =>{
                  console.log("err",response);
                   loading.close();
                   loading.close();
                        this.$message({
                            showClose: true,
                            message: response.message,
                            type: "error"
                        });
                })

`

Mar.02,2021

specification, but it can be implemented with interceptors axios.interceptors.request and axios.interceptors.response , otherwise it's really tiring.

it's better to post a code instead of a sticker

when asking a question. There is a syntax error in

then. If an exception is thrown, it will also go to the catch () callback, which is not necessarily a network error.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3068e-2bd3d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3068e-2bd3d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?