This question already has an answer here:
Quasar framework q-select sets an object in the v-model than the id (1 answer)
Closed 6 days ago.
I'm having a problem sending the value of a select to my database. I'm using Vue, quasar and typescript.
I have a modal with name and age inputs, in addition I have a select that selects a category. But, when sending this select value to the database, an object is sent with the label and value of the select. But the database would only accept it if it was a numeric value.
const baseFieldStates = {
name: '',
age: '',
category: null,
};
//@ts-ignore
const fieldStates: Ref = ref({
...baseFieldStates,
...props.userData
});
Here would be my function to save a user and send their data.
const userAction = props.userData ? editUser : createUser
const saveUser = () => {
userAction(fieldStates.value)
.then(() => {
onDialogOK(fieldStates.value);
})
.catch(() => {
onDialogCancel();
})
};
My select:
This is an example of how my select is sent to the database.
{label: 'Example', value: 1}
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)