You need to use the request-promise module, not the request module.
await working on functions that return a promise, not functions that return a request object, and expect you to use callbacks or event listeners to know when everything will be done.
The request-promise module supports the same functions as the request module, but the asynchronous functions in it return promises, so you can use .then() or await with them, and not the callbacks that the request module expects.
So, install the request-promise module , and then change this:
var request = require("request");
:
var request = require("request-promise");
source share