Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

351
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda