Encapsulate an axios method. Solve asynchronous problem

function logina (id, password) {
let url = "url";
let json = {

loginid: id,
password: password

};
let result = Post (url, json, null);
console.log (1, result);
return result;
}

function Post (api, post, headers) {
let result = false;
axios.post (api, post, {headers: headers})

.then((function(response) {
  console.log("post", response);
  return response;
}))
.catch(function(err) {
  console.log(err);
  return result;
});

}

The

code is shown above, and if successful, the result executed by console is undefined. After that, the corresponding data of post will be returned. How to make result return the data of response

Jun.24,2021

function Post(api, post, headerscallback) {
let result = false;
axios.post(api, post, { headers: headers })

.then((function(response) {
  console.log("post", response);
  callback(res);
  return response;
}))
.catch(function(err) {
  console.log(err);
  return result;
});
}

A successful callback returns res
post (apiurl, post, header,function (res) {

 console.log(res)

})

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