How to establish a websocket connection in the Checkout UI extension

How to establish a websocket connection in the Checkout UI extension

themistoklis-bo
Shopify Partner
1 0 1

Hello, 

I'm trying to establish a websocket connection in the Checkout UI extension.
I tried with the library react-stomp-hooks

<StompSessionProvider url={"ws://localhost:8080/ws"}>
Hello
</StompSessionProvider>


I tried this code in a react app and i connected successfully but in checkout ui extension i get the following error

StompSessionProvider.tsx:34 Uncaught (in promise) ReferenceError: window is not defined
    at r.brokerURL.r.webSocketFactory.i.webSocketFactory (StompSessionProvider.tsx:34:40)
    at Client._createWebSocket (client.ts:522:24)
    at Client.<anonymous> (client.ts:447:28)
    at Generator.next (<anonymous>)
    at fulfilled (droner-checkout-extension.js:67:26)


Is there any example or documentation on how to connect to a websocket in a checkout ui extension?

Replies 0 (0)