Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

354
Visualizações
Twitter API - How to check if a specific user liked a specific tweet?

I'm using the twitter v2 API for node, I can pull all users who liked a twitter and use an if in a loop, to check if the user I want is inside the array, but depending on if the tweet has many likes the loop it becomes too long.

I would like to know if there is a way to go straight to the information without needing the loop, if there is any filter or something.

    const client = twitterApi({ token, secret })
    const usersLiked = await client.v2.tweetLikedBy(target, {
      asPaginator: true,
    })

    for await (const user of usersLiked) {
      if (user.id === userIdTwitter) {
        await task.related('users').attach([userId])
        return response.ok({})
      }
    }

    return response.notFound()

about 4 years ago · Santiago Gelvez
1 Respostas
Responde à pergunta

0

The binary search might help you in this situation. Binary search is a search algorithm that divide the search making it faster witch is better than looking and comparing one by one. An import detail is that this array should be in ascending order before searching. I hope I have been helpful somehow.

about 4 years ago · Santiago Gelvez Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda