I dont know why ? but per observation , i cannot connect to server when the client instantiation happens inside of the class method and call it later when needed
for example
then will call the callexpress when a certain button event clicked , but it does not connect ,
EDIT:
i can connect from class when starting the app.js and immediately call the class and method , but it does not connect when the app.js already up and then call the class with the method when the button clicks ,
I dont know why ? but per observation , i cannot connect to server when the client instantiation happens inside of the class method and call it later when needed for example
class MyClient{ async callExpress(){ const client = new Client({ path: socketPath }); console.log(JSON.stringify(client)) try { const response = await client.post("/network/login", { username: "admin", password: "admin" }); console.log(response); } catch (ex) { console.log(ex); }
client.close(); } }
then will call the callexpress when a certain button event clicked , but it does not connect ,
EDIT: i can connect from class when starting the app.js and immediately call the class and method , but it does not connect when the app.js already up and then call the class with the method when the button clicks ,