I have single page application with an Angular frontend and a Spring REST-backend.
What is the proper way to handle a list of string-based options in the fronted the enduser can select from, which shall all be shown and eventually slightly changes over time?
i.e. gender (‘Male’, ‘Female’, ‘Unisex’) or jobs (‘Student’, ‘Teacher’, ‘Engineer’, …)
- Store the lists as a key-value pair, i.e. gender (‘Male’ 0, ‘Female’
1, ‘Unisex’ 2) and jobs (‘Student’ 0, ‘Teacher’ 1, ‘Engineer’ 2, …)
- have an own GET-endpoint for every list (gender, jobs, …) to fetch the key/value mapping
- backend only stores the id, mapping from id to value will be done in the frontend with the fetched list
- is there a best-practise for this?
- should I use key/value pairs at all or just store the strings itself as they are presented in the frontend?
- should I use a GET-endpoint to fetch the lists at all, or should I just hardcode them in the frontend?
- maybe forget about all this and do it differently?
Thanks in advance!