0

I am getting object Object in the select dropdown list

Here is my code

<q-select v-model="product_category" :options="options" label="Project Category" />

Script code

data () {
return {
  options: [],
 }
},
created () {
this.$axios.get([
  'http://127.0.0.1:8000/api/lailen-inventory/categories'
])
  .then(res => {
    this.options = res.data.categories
  })
}

2 Answers 2

2

I think you have to add option-label and option-value props on the <q-select> tag. If your res.data.categories (for example) looks like this

[
  { id: 1, name: 'water' },
  { id: 2, name: 'earth' },
  { id: 3, name: 'fire' },
  { id: 4, name: 'air' }
]

then your <q-select> tag should look like this

<q-select
  v-model="product_category"
  :options="options"
  option-value="id"
  option-label="name"
  label="Project Category"
/>
Sign up to request clarification or add additional context in comments.

2 Comments

this solved my issue ty
sure, happy to help
0

You could make your value an object containing the type and id. Like this:

data () {
    selectOptions: [{
        label: yourInitialObject.title,
        value: {
           id: yourInitialObject.id,
           type: yourInitialObject.type
        }
    }]
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.