I have the following problem, I need to send the response of a request to the view and I don't know how to do it since I am new with Node. I looked everywhere but found nothing.
var app = require('express')();
var http = require('http').Server(app);
var rp = require('request-promise');
var options = {
uri: 'http://tapas.clarin.com/tapa/1990/02/22/19900222_thumb.jpg',
headers: {
'User-Agent': 'Request-Promise'
},
json: true // Json parse
};
rp(options)
.then( res => {
console.log(res)
})
.catch(function (err) {
console.log(err)
});
http.listen(3000, function(){
console.log('listening on localhost:3000');
});
Printing this line gives console.log(res)
me the binary image on the console, but what I need is to send that image to the view to be displayed. Any idea how to achieve it?
My view is very simple:
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Tapas Clarin</title>
</head>
<body>
<div id="tapas">
<!-- Acá quiero mostrar la imagen -->
</div>
<script src="./app.js"></script>
</body>
</html>
Thank you very much