I am trying to figure out how this works. Is it possible to run the code inside script tags in the Hello-Example from node and not within the browser that is hosts it?
How this can be achieved that?
I copy the code in a nodeclient.js file, i installed the Resclient through npm in my test project and i replaced the “document.body” lines with console log as below
const resclient = require('resclient');
const ResClient = resclient.default;
let client = new ResClient('ws://localhost:8080');
client.get('example.model').then(model => {
console.log(model.message);
//document.body.textContent = model.message;
}).catch(err => {
console.log("error-->", err);
//document.body.textContent = "Error getting model. Are NATS Server and Resgate running?";
});
and the message after running this with node client.js is
error--> ResError {
rid: 'example.model',
method: 'subscribe.example.model',
params: undefined,
_code: 'system.unknownError',
_message: 'WebSocket is not defined',
_data: undefined }
while i have an open browser that responds with “Hello World” as expected
Thank you