Let's say, I have a class like this:
var block = class {
constructor(val1, val2) {
this.value1 = val1;
this.value2 = val2;
}
}
I want to send an instance of this class from one server to another. I would typically pass it through JSON.stringify()
before sending it to the other server, then JSON.parse()
once it reaches the other server. However, this would involve converting it to JSON and it would no longer be an instance of the 'block' class.
If I wanted to send it over in a way that keeps it as an instance of the 'block' class what would be best practice.