C
C#2y ago
oe

Is this the right way to save state of my ASP.NET/Angular app as a URL?

I have an ASP.NET Core + Angular project. Once a file is uploaded to my ASP.NET API, a JSON is returned which is used by the Angular frontend. I want to be able to click a SAVE button in frontend, and save that exact state of the APP to a URL (ie: example.com/r/wrhwrthj). I thought of a way to do this. 1) When the save button is clicked, the JSON is sent to an API: POST URL: /SaveState/ BODY: jsonString 2) The API uses entity framework to save the current state to a MySQL table of { StateID, StateValue } 3) If Angular detects a route of /r/{x}, it requests the JSON from /GetState?id={x} Is this a good approach to the problem I'm trying to solve? Will appreciate all feedback. Thank you!
2 Replies
Angius
Angius2y ago
Yeah, seems perfectly reasonable If the state is structured JSON, I'd probably go one step beyond, and use a database with JSONB support, instead of storing plain strings Never know when you'd want to query the states or something
oe
oeOP2y ago
Great, thank you
Want results from more Discord servers?
Add your server