N
N
nosazus2017-05-24 21:26:51
JavaScript
nosazus, 2017-05-24 21:26:51

How to select each object from an array and number links from it?

I make a request to swapi.co and get an array results consisting of a bunch of unnumbered objects with no id.

asyncData ({ req, params }) {
    return axios.get('http://swapi.co/api/people/')
    .then((res) => {
      return { people: res.data.results }
    })
  }

I need to generate links like swapi.co/api/people/1, swapi.co/api/people/2 and so on (i.e. numbers, by the number of given objects in the array). and paste them here:
<li v-for="person in people">
   <nuxt-link :to="{ name: 'user-user', params: { user: СЮДА } }">LINK</nuxt-link>
</li>

How to do it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Igor Koch, 2017-05-24
@nosazus

Use index?
https://vuejs.org/v2/guide/list.html
v-for="(item, index) in items"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question