I have three pages: server.js, user.js, index.js. my server takes data from the request header and builds a User object. the user object has a method that does calculate and save at result. I want to pass the result to index.js or to an HTML page and manipulate the result. I try to save the result in a static verb and create obj in the index.page. but I get Error. any idea how to do that?
//server.js
const User = require('./user.js');
var express = require('express');
var app = express();
app.get('/', function(req, res) {
res.sendFile(__dirname + '/index.html');
console.log("connecting to server");
jsonHeader = JSON.stringify(req.headers);
user = CreateUserObject(req);
User.setResult(30); }
// user.js
class User{
constructor(){
this.ip=0;
this.language =' ';
this.result = "";
}
setUserDetails(requestHeader){
this.Ip = requestHeader.header('x-forwarded-for');
this.language = requestHeader.header('accept-language');
}
setResult(number){
User.staticResult = number;
}
getResult(){
return User.staticResult;
}
};
User.staticResult = 15;
module.exports = User;
//index.js
import User from 'user.js';
var user = new User();
................