Skip to content

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”.

  getId: (state) => (LotofID, id) => { => {
      if ( === id)
        return (obj);

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

var test = [] => {
    test.push(this.$store.getters.getId(LotofID, obj))

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


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

 getId: (state) => (LotofID, id) => {
    return LotofID.points.find(obj => === id)