0

I am trying to use find function in this array

array=  [{
        type: 'banks',
        id: 25,
        attributes: { name: 'Bradescard', bankNumber: '063' },
        links: { self: '/banks/63' }
      },
      {
        type: 'banks',
        id: 26,
        attributes: { name: 'BM Goldman Sachs', bankNumber: '064' },
        links: { self: '/banks/64' }
      },
      {
        type: 'banks',
        id: 27,
        attributes: { name: 'Bracce', bankNumber: '065' },
        links: { self: '/banks/65' }
      }
    ]

if I try find(propEq('id', 27))(array) it returns the correct object, but I need to find by bankNumber.

皇冠hg0088代理网址I tried find(propEq(lensPath(['attributes', 'bankNumber']), '065'))(array) but I got undefined

皇冠hg0088代理网址How can I do this?

2

Try to just switch propEq to pathEq.

Something like: find(pathEq(['attributes', 'bankNumber'], '065'))(array).

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.