I have an image API running from a home server, and I'm building a cloud-hosted page that grabs the image in backend and shows it, for a layer of abstraction.
Here's what I'm trying to do:
index.js
var express = require('express');
var router = express.Router();
router.get('/', function(req, res, next) {
// some logic to grab the image and pass it to the HTML page
// var image = fetch("myimageapi.com")
// ?????
res.render('index', {page:'Home', menuId:'home'});
});
and display it with <img id="myimage">
Or maybe it would be better to:
router.get('/', function(req, res, next) {
res.render('index', {page:'Home', menuId:'home'});
});
router.get('/image', function(req, res, next) {
//fetch image
});
and <img src="mywebsite.com/image>
I really have no idea how one would go about doing this in node, I am coming from python and this is all very scary