Skip to content
Advertisement

Passing an array object property from Laravel in Vue

I am sending an article->tags array of objects to my Vue component like so:

JavaScript

I get this array:

JavaScript

Now in my component, I want to get to the name field so I can store it and pass it onwards. How can i do this?

this post has the same problem, but when i try this solution:

JavaScript

I get an undefined.

Advertisement

Answer

for...in loops are for objects, but you have an array. Try a for...of loop:

JavaScript

or forEach:

JavaScript

or for loop:

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement