Modified the JavaScript code to connect the ServerEndpoint