Closed besanur closed 6 months ago
Hi,
I think it is best to see the JSON from your external API and the JSON created by the serialization for StatefulService completely separate. Instead of overwriting the file on the FS you can just parse it and write it into the variables directly. CustomTimeState
is accessible as _state
in the CustomTimesService
class. After you've stored your external API results you can trigger an update by calling
_state.callUpdateHandlers("externalAPI");
The same logic can be used to update the display by simply reading from _state.selectedCity
.
Hi,
I think it is best to see the JSON from your external API and the JSON created by the serialization for StatefulService completely separate. Instead of overwriting the file on the FS you can just parse it and write it into the variables directly.
CustomTimeState
is accessible as_state
in theCustomTimesService
class. After you've stored your external API results you can trigger an update by calling_state.callUpdateHandlers("externalAPI");
The same logic can be used to update the display by simply reading from
_state.selectedCity
.
Ok thank you i will try this
@besanur Did this work for you? Can I close this issue as solved?
Yes, thank you, you can close it.
Hello, I would like to save a Json Object in the FileSystem via Http. I then want to read the values from the FS in my CustomStateService.
What is the best way to do this in the backend? I have already done the frontend part, the id is set and a rest endpoint should be called. But I would like to save this ID in the file system in the backend and then read it somewhere else. For an Http rest call to an external service. Which in turn gives me a Json response and I save it back into the file system.
I'm currently also using my own code to save the result of the external service call in the FS. Can I also use the FSPersisntence for this somehow?
Here is the code I use...