I try to get the image and display on a url. and I use request module.
For example, I want to get the image https://www.google.com/images/srpr/logo11w.png, and display on my url http://example.com/google/logo.
Or display by <img src="http://example.com/google/logo" />.
And I try to use request and express:
app.get("/google/logo", function(req, res) {
request.get("https://www.google.com/images/srpr/logo11w.png",
function(err, result, body) {
res.writeHead(200, {"Content-Type": "image/png"});
res.write(body);
res.end();
})
})
but the response is not a image. How to get image and output?
Please give me some suggestion about the question. THANKS.