When getting data from the service, I want to use Fetch to grab the data, and then assign it to receiveData. How can I achieve this?

I want to use Fetch to grab the data and return the captured data, but now I call the postFromServer function. I can"t wait for Fetch, to return a undefined, directly. How can I solve this problem?

module.exports = {
    postFromServer ( requestParam ) {
            const _self = this;
            let url = requestParam["url"] || "";
            let headers = requestParam["headers"] || "";
            let postBody = requestParam["postBody"] || "";
            let response = _self.sendToServer( url, "POST", headers, postBody );

            response.then(function(value) {
                console.log(" value === ", value)
                if( value["code"] === 200 ) {
                    return value
                }
            }, function(error) {
                console.log(" error === ", error)
            });
        }
}
import Helper from "common-helper-es6";
let receiveData = await Helper.postFromServer( requestParam );
Jun.09,2021

just add a return

module.exports = {
    postFromServer ( requestParam ) {
            const _self = this;
            let url = requestParam['url'] || '';
            let headers = requestParam['headers'] || '';
            let postBody = requestParam['postBody'] || '';
            let response = _self.sendToServer( url, 'POST', headers, postBody );

            return response.then(function(value) {
                console.log(' value === ', value)
                if( value['code'] === 200 ) {
                    return value
                }
            }, function(error) {
                console.log(' error === ', error)
            });
        }
}

return response.then...
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-1b22858-2b617.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-1b22858-2b617.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?