Imagine I have a straightforward API for user registration. This API collects basic information like Name, email, state, gender, and marital status for each user. I already have database tables pre-populated with ids for state, gender, and marital status options which are displayed in dropdowns for users to select.
Now, when it comes to my API controller for registering users, should I pass the list of values as a single JSON object like this?
return response()->json([
'genderList' => Gender::get('id', 'name'),
'stateList' => State::get('id', 'abbr'),
'maritalList => MaritalStatus::get('id', 'name')
]);
Alternatively, should I create separate controllers and API calls for each of these lists, with each call returning a single object?
Is there a standard approach to handling this, or is it more of personal preference?
Just so you know: I'm using Vue.js for my frontend.