I have a web page where I receive a messages from web socket:
useEffect(() => {
let feedAddress = "ws://.../ws_endpoint";
const feedClient = new W3CWebSocket(feedAddress);
props.onUpdateWebsocket(feedClient);
feedClient.onopen = () => {
console.log("WebSocket Client Connected on " + feedAddress);
};
feedClient.onmessage = (message) => {
let payload = JSON.parse(message.data);
// parse here the response message
};
}, []);
I can have 2 types of messages:
success:
{
"requestId" : <string>,
"response" : {
"exchange": <string>,
"messageId" : <string>
}
}
error:
response: {
"errorMessage" : <string>,
"errorCode" : <int>
}
How I can parse both types of messages and display warning messages with the both types of responses as dialog messages?