0

How do i access the full course array enter image description here

the code below gives me the first course array.

<div class="form-group"  v-show="school === 'SOSE'">
      <label for="course">Course</label>
      <select class="form-control" name="course" v-model="course">
        <option v-for="(result, index) in response" :value="result.course[0].initial">{{result.course[0].name}}</option>
      </select>
    </div>

if i use the index, course becomes undefined. How do i get values in both arrays.

Code for fetching data.

created() {
    axios.get(`https://${location.host}/admin/getSchool`)
      .then(resp => {
        this.response = resp.data;
        console.log(this.response);
      })
      .catch(err => {
        this.errors.push(err);
      })
  },

2 Answers 2

1

You will have to use two v-for here I used the template tag for it.

  <select class="form-control" name="course" v-model="course">
    <template v-for="result in response">
      <option v-for="course in result.course" :value="course.initial">{{course.name}}</option>
    </template>
  </select>
Sign up to request clarification or add additional context in comments.

1 Comment

It worked like a charm; spent more than 3 hours on this. A heavy load of my head. Thanks
0

nodejs

try

result.forEach(function(item){
    console.log('initial: ' + item.initial);
    console.log('name: ' + item.name);
});

Hope it will be useful

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.