Skip to content
Advertisement

Undefined when i am returning an Object in Javascript

I’m doing a getter in VueX, and when i’m returning an object for another function, i have “undefined”.

JavaScript

Basically i have a function like that. When i’m showing obj with console.log(obj), i have an object with elements in here. And basically it’s working. But when i’m doing a return and i’m trying to get the obj in another function

JavaScript

I have a “undefined” in my variable. Anyone have an idea of where the problem can be

Advertisement

Answer

You should use find method instead of map and return the found item inside your getter:

JavaScript
Advertisement