mirror of
https://github.com/wisplite/tether-ts.git
synced 2026-05-01 06:22:41 -05:00
fix json parsing error
This commit is contained in:
+2
-2
@@ -52,8 +52,8 @@ export class TetherClient {
|
||||
mutation_id: mutation_id
|
||||
}));
|
||||
return new Promise((resolve, reject) => {
|
||||
this.websocketHandler.onMutation = (data) => {
|
||||
if (data.mutation_id === mutation_id) {
|
||||
this.websocketHandler.onMutation = (mutation_id: string, data: any) => {
|
||||
if (mutation_id === mutation_id) {
|
||||
resolve(data);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -8,7 +8,7 @@ export class WebSocketHandler {
|
||||
private maxReconnectAttempts: number = 5;
|
||||
private reconnectInterval: number = 1000;
|
||||
private sendQueue: string[] = [];
|
||||
public onMutation: (data: any) => void = () => {};
|
||||
public onMutation: (mutation_id: string, data: any) => void = () => {};
|
||||
startConnection = (url: string) => {
|
||||
this.url = url;
|
||||
this.ws = new WebSocket(url);
|
||||
@@ -30,11 +30,12 @@ export class WebSocketHandler {
|
||||
location?: string;
|
||||
data?: unknown;
|
||||
error?: string;
|
||||
mutation_id?: string;
|
||||
};
|
||||
if (data.type === 'query') {
|
||||
this.onQuery(data.location, data.data);
|
||||
} else if (data.type === 'mutation') {
|
||||
this.onMutation(data.data);
|
||||
this.onMutation(data.mutation_id || '', data.data);
|
||||
} else if (data.type === 'error') {
|
||||
console.error(data.error);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user