Как найти объект в массиве?
import React from 'react'
import { useSelector } from 'react-redux';
import { useParams } from 'react-router-dom';
export default function User(props) {
const { gistName } = useParams()
const gists = useSelector(state => state.gists.data)
const item = gists.find(item => item.files.`${gistName}`.filename === gistName);
console.log(item)
return (
<div>
</div>
)
}
Нужно найти объект в массиве зная имя файла
data: [
{
url: 'https://api.github.com/gists/55f8d84eaecb5e50eae9acd6120f2298',
forks_url: 'https://api.github.com/gists/55f8d84eaecb5e50eae9acd6120f2298/forks',
commits_url: 'https://api.github.com/gists/55f8d84eaecb5e50eae9acd6120f2298/commits',
id: '55f8d84eaecb5e50eae9acd6120f2298', // этот id
node_id: 'MDQ6R2lzdDU1ZjhkODRlYWVjYjVlNTBlYWU5YWNkNjEyMGYyMjk4',
git_pull_url: 'https://gist.github.com/55f8d84eaecb5e50eae9acd6120f2298.git',
git_push_url: 'https://gist.github.com/55f8d84eaecb5e50eae9acd6120f2298.git',
html_url: 'https://gist.github.com/55f8d84eaecb5e50eae9acd6120f2298',
files: {
'LinkToken_Matic.v6.sol': {
filename: 'LinkToken_Matic.v6.sol', //зная filename нужно найти id,
type: 'text/plain',
language: 'Solidity',
raw_url: 'https://gist.githubusercontent.com/krebernisak/55f8d84eaecb5e50eae9acd6120f2298/raw/587e88112d280ca3dcc6e0b834cbc24ebbe5389d/LinkToken_Matic.v6.sol',
size: 30783
}
},
'public': true,
created_at: '2020-10-21T14:48:04Z',
updated_at: '2020-10-21T14:48:05Z',
description: 'LinkToken on Matic Network v6',
comments: 0,
user: null,
comments_url: 'https://api.github.com/gists/55f8d84eaecb5e50eae9acd6120f2298/comments',
owner: {
login: 'krebernisak',
id: 615877,
node_id: 'MDQ6VXNlcjYxNTg3Nw==',
avatar_url: 'https://avatars0.githubusercontent.com/u/615877?v=4',
gravatar_id: '',
url: 'https://api.github.com/users/krebernisak',
html_url: 'https://github.com/krebernisak',
followers_url: 'https://api.github.com/users/krebernisak/followers',
following_url: 'https://api.github.com/users/krebernisak/following{/other_user}',
gists_url: 'https://api.github.com/users/krebernisak/gists{/gist_id}',
starred_url: 'https://api.github.com/users/krebernisak/starred{/owner}{/repo}',
subscriptions_url: 'https://api.github.com/users/krebernisak/subscriptions',
organizations_url: 'https://api.github.com/users/krebernisak/orgs',
repos_url: 'https://api.github.com/users/krebernisak/repos',
events_url: 'https://api.github.com/users/krebernisak/events{/privacy}',
received_events_url: 'https://api.github.com/users/krebernisak/received_events',
type: 'User',
site_admin: false
},
truncated: false
},