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 );