The current approach of declaring all form fields first and then populating them one by one after the axios call is not the best practice. A better approach would be to use the setFormFields method provided by Inertia's useForm hook to set all the form fields at once. Here's an example:
const api_response = ref({});
const form = useForm({
field1: null,
field2: null,
field3: null,
field4: null,
field5: null,
field6: null,
field7: null,
field8: null,
field9: null,
});
onMounted(() => {
axios.get('some url').then(function (response) {
api_response.value = response.data;
form.setFormFields(response.data.user);
});
});
This way, all the form fields will be set at once, and the loading icon will spin until the axios call is completed.