Im trying to get a text from a website and put the text in a variable. I then want to have an if statement, if the variable == "something" then do function. As of now, here is my code, I cannot seem to define a variable in the function. If I do, I cannot use the variable outside the function for my if statement
const superagent = require('superagent');
(async function(){
const response = await superagent.get('https://www.google.com')
var text = (response.text)
})();
if (text == "something"){
//do something
}
My code above returns "text is not defined"