Replies: 1 comment 11 replies
-
So, there are two ways to approach this. The intended way to use SSE in htmx is to send HTML fragments instead of JSON (just like you would with normal requests). See the examples here https://htmx.org/extensions/server-sent-events/. However, if you have to use JSON, there is a way around it by using client side templates extension https://htmx.org/extensions/client-side-templates/. Just add the attribute with templating engine of your choice to the element that connects to SSE endpoint and you should be good to go. Also, hx-sse is not quite supported and kept for backward compatibility. You should use SSE extension https://htmx.org/extensions/server-sent-events/ instead (migration guide is at the bottom of the page) |
Beta Was this translation helpful? Give feedback.
-
Hi there,
I very new so please excuse me if my question may be wrong or strange
I am sending currency rates from backend (FASTAPI) by using SSE and in data I am sending json format data it's like:
[{'symbol': 'BTCUSDT', 'price': '21418.71000000'}, {'symbol': 'DOGEUSDT', 'price': '0.07382000'}]
in the test.html file I used below code
the result is realtime but i see whole json data"
[{'symbol': 'BTCUSDT', 'price': '21418.71000000'}, {'symbol': 'DOGEUSDT', 'price': '0.07382000'}]
how can I fix this and be able to whole currency rate or any kind of json data online?
Beta Was this translation helpful? Give feedback.
All reactions