0
I’m trying to get the HTML of any URL (Google for example), to use it in my front end. First, I try my server.js Node with Express to get this HTML through the "request module":
app.get('/geradorPreview', (req, res) =>{
var retorno = null
request('http://www.google.com', function (error, response, body) {
console.log(body) //IMPRIME CORRETAMENTE O HTML
retorno = body;
})
console.log(retorno) // imprime null
res.send({ret: retorno})
})
In the first console.log, what is printed on my terminal is the HTML I requested. So I try to assign this body content to the return variable. But by giving her console.log below, she’s still null, and I can’t use the contents of the body variable.
Tips?