Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia
TypeScript apiapi-clientapi-restapi-testingdeveloper-toolsgraphqlhttphttp-clientpwarestrest-apispatestingtesting-toolstoolsvuevuejswebsocket
Trying to json parse user input so that the socket io library can properly emit json data. Falls back to string input
Dan Fey266cb83ba9d9
diff --git a/components/realtime/socketio.vue b/components/realtime/socketio.vueindex 207980536..1f57cdb1c 100644--- a/components/realtime/socketio.vue+++ b/components/realtime/socketio.vue@@ -144,13 +144,13 @@ export default {ts: new Date().toLocaleTimeString(),})})- this.io.on("connect_error", error => {+ this.io.on("connect_error", (error) => {this.handleError(error)})- this.io.on("reconnect_error", error => {+ this.io.on("reconnect_error", (error) => {this.handleError(error)})- this.io.on("error", data => {+ this.io.on("error", (data) => {this.handleError()})this.io.on("disconnect", () => {@@ -194,12 +194,18 @@ export default {},sendMessage() {const eventName = this.communication.eventName- const message = this.communication.input+ let message++ try {+ message = JSON.parse(this.communication.input)+ } catch (err) {+ message = this.communication.input+ }if (this.io) {// TODO: support only one argument now// maybe should support more argument- this.io.emit(eventName, message, data => {+ this.io.emit(eventName, message, (data) => {// receive response from serverthis.communication.log.push({payload: `[${eventName}] ${JSON.stringify(data)}`,@@ -209,7 +215,7 @@ export default {})this.communication.log.push({- payload: `[${eventName}] ${message}`,+ payload: `[${eventName}] ${JSON.stringify(message)}`,source: "client",ts: new Date().toLocaleTimeString(),})