node.js
const request = require(`request`);
function doRequest(options) {
return new Promise(function (resolve, reject) {
request(options, function (error, res, body) {
if (!error && res.statusCode == 200) {
resolve(body);
} else {
reject(error);
}
});
});
}
とすれば
node.js
const hoge = async () =>{
const requestOptions = {
url: url,
method: "POST",
headers: headers,
json: payload
}
const res = await doRequest(requestOptions)
}