How to update a state variable from a FastAPI POST route? #5942
-
|
Hi! I’m new to Reflex and I’m trying to connect it with FastAPI. What is the correct way to modify a state variable from a FastAPI route? Thanks in advance — I’m just getting started with Reflex and trying to learn! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
first you need to send the then you need to use that token to get the associated state and modify it when the context exits, the value will be persisted and sent to the client (if they are still connected). prior to 0.8.17, if the client had reconnected to a different app instance, then the update would not have been sent. |
Beta Was this translation helpful? Give feedback.
first you need to send the
tokenthrough with your POST request -- get can get this fromsessionStorage.get("token")or by callinggetTokenfrom$/utils/state.js.then you need to use that token to get the associated state and modify it
when the context exits, the value will be persisted and sent to the client (if they are still connected).
prior to 0.8.17, if the client had reconnected to a different app instance, then the update would not have been sent.