I have an image on my frontend. I am storing the right click image coordinates in a javascript object. On the other hand I have made an api using nodejs and I want to display this object when I call it through the api, on the web browser. The name of the object is imageCoord. Here is my nodejs code:
console.log('server is starting');
var express = require('express');
var app = express();
var server = app.listen(3000, listening);
function listening() {
console.log('Listening...');
}
app.use(express.static('website'));
app.get('/imgcoords', sendImgCoords);
function sendImgCoords(request, response){
response.send(imageCoord);
}
I am trying to call the object in the callback function just by its name as this object is a global variable in my frontend code but I am getting a reference error. How can I call this object into this code so that I can get the desired result?