[Vuejs]-How to get API using axios in nuxt.js?

3๐Ÿ‘

โœ…

I suppose that response is an object that contains the property data (see docs) which (in this case) holds an array of objects.
Assuming you want to save postId, email and name for every comment in items, you could try this:

const response = await axios.get('https://jsonplaceholder.typicode.com/posts/1/comments');

this.items = response.data.map(comment => ({
  postId: comment.postId,
  email: comment.email,
  name: comment.name,
}));
๐Ÿ‘คsandrooco

Leave a comment