WeChat Mini Programs encapsulates the request how to intercept the request verification token?

use login to get Wechat code, and use Wechat code to get token, because token will fail, so you need to intercept whether the token is valid for each API call. If it is valid, if you do not make any changes, you will jump to the login page. How to encapsulate wx.result, on the code feed code, heh heh!

Oct.11,2021

package yourself

let responseSuccess = (response, success, failure, autoAlert) => {

}

let responseFailure = (response) => {

}

module.exports = {

    get: (uri, success, failure, autoAlert=true) => {

        wx.request({
            url: host+uri,
            method: "GET",
            header: getHeader(),
            success: (response) => {
                responseSuccess(response, success, failure, autoAlert)
            },
            fail:  responseFailure
        })

    },
    post: (uri, data, success, failure, autoAlert=true) => {

        wx.request({
          url: host + uri,
            method: "POST",
            header: getHeader(),
            data: Util.usNameWithObject(data, true),
            success: (response) => {
                responseSuccess(response, success, failure, autoAlert)
            },
            fail:  responseFailure
        })

    },
    put: (uri, data, success, failure, autoAlert=true) => {

        wx.request({
          url: host + uri,
            method: "PUT",
            header: getHeader(),
            data: Util.usNameWithObject(data, true),
            success: (response) => {
                responseSuccess(response, success, failure, autoAlert)
            },
            fail:  responseFailure
        })

    },
    del: (uri, success, failure, autoAlert=true) => {

        wx.request({
          url: host + uri,
            method: "DELETE",
            header: getHeader(),
            success: (response) => {
                responseSuccess(response, success, failure, autoAlert)
            },
            fail:  responseFailure
        })

    }

}
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-1b4159b-34951.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-1b4159b-34951.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?