Depending on what version of node you are using I would just setup an Observable or whatever front end library I am using implementation of it. You can find example of this all over stack.
How to observe value changes in JS variables