Answer the question
In order to leave comments, you need to log in
How to address such an answer?
I have this api answer
[
{
"id": 1,
"category_name": "porro",
"created_at": "2022-04-02T21:29:52.000000Z",
"updated_at": "2022-04-02T21:29:52.000000Z",
"posts": [
{
"id": 2,
"title": "Culpa quis praesentium.",
"description": "Repudiandae distinctio qui quia natus tempora ullam culpa totam.",
"image": null,
"created_at": "2022-04-02T21:29:52.000000Z",
"updated_at": "2022-04-02T21:29:52.000000Z",
"pivot": {
"categories_id": 1,
"posts_id": 2
}
}, ....
<div v-for="post in posts">
{{ post.category_name }}
<br>
</div>
posts:for example, get the title?
<div v-for="post in posts.posts">
{{ post.title }}
<br>
</div>
<div v-for="post in posts.posts.data">
{{ post.title }}
<br>
</div>
<div v-for="post in posts['posts']">
{{ post.title }}
<br>
</div>
Answer the question
In order to leave comments, you need to log in
either v-for="post in posts[0].posts" if it so happened that all the posts are inside, and outside there is one object in the array, or v-for="post in posts" and inside v-for=" post in post.posts" it's
better to rename something like this so there's no confusion
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question