Instantly share code, notes, and snippets.

Embed
What would you like to do?
HTTPS requests using Node.js and async / await through the request-promise-native module
const rp = require("request-promise-native");
async function processData() {
try {
let response = await rp("https://www.andreasjakl.com/");
if (response.length > 100) {
let response2 = await rp("https://www.andreasjakl.com/wp-content/uploads/2018/08/arcore-anchors.gif");
console.log("Data: ", response2.substring(0,10));
}
} catch (error) {
console.log("Error: ", error);
}
}
processData();
console.log("Starting...");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment