I have a function that uses the request-promise module to scrape and parse HTML from a website. I want the function to just return some JSON data when it's done, and not a promise.
Here's the slimmed down version of the code I have so far:
const rp = require('request-promise');
const URL = 'http://example.com/';
async function get_data() {
let get_data_wrapper = (async () => {
let html = await rp(URL);
let var1 = {};
// Do stuff so that var1 contains JSON data
return var1;
});
return await get_data_wrapper();// Return courses promise
}
Preferably, I would like to have get_data() return just the JSON data, as opposed to a promise.
Am I thinking about all this in the wrong way?