Wx.request

I saw the code written by someone:

wx.request.post().then();

that"s what he wrote about renquest. Why is it followed by a. Then ();
. Then it can"t be used in ordinary functions? Is it possible for him to use it like this only after he has made it easier to use it?

Apr.11,2021

indicates that the return value of this function is a Promise object


I use the following to implement Promise :
promisify.js

module.exports = (api) => {
    return (options, ...params) => {
        return new Promise((resolve, reject) => {
            api(Object.assign({}, options, { success: resolve, fail: reject }), ...params);
        });
    }
}

then wrap wx.request

const promisify = require('./promisify.js')
request = promisify(wx.request)

request({
    method: 'POST',
        url: url,
        data: data,
        header: {
            'content-type': 'application/x-www-form-urlencoded' //application/json
        },
}).then(...)

A post with success and fail can be encapsulated here, so that method and header

can be avoided every time.
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-1b363bb-2bfe0.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-1b363bb-2bfe0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?