1function doRequest(url) {
2 return new Promise(function (resolve, reject) {
3 request(url, function (error, res, body) {
4 if (!error && res.statusCode == 200) {
5 resolve(body);
6 } else {
7 reject(error);
8 }
9 });
10 });
11}
12
13// Usage:
14
15async function main() {
16 let res = await doRequest(url);
17 console.log(res);
18}
19
20main();