I create a object in a Node server and a send it throught Jade:
module.exports = class Object {
constructor() {
this.foo = "bar";
}
getFoo() {
return this.foo;
}
}
Server.js file:
var ob = new Object();
app.get('/', function (req, res) {
res.render('index', {object : ob});
});
When I try to use the object on the client
var ob = !{JSON.stringify(object)};
console.log(ob.getFoo());
I get the error that the variable "ob" has no function "getFoo", the client requests object.js where is described the Object class. I don't think this is the right way, but it's the only one I know.
First question, non native English speaker, hope everything is at least fine.