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

158
Visualizações
How do I filter through API information to find a perfect match of a specific search param in React?

I have an API call returning 1 movie name at random... The code has it set up so it returns 1 movie name only.

I then have a second API call that uses that movie name in a second axios request to find streaming services available for this specific movie title.

My issue is, the second API call returns an array of 20 or so choices. For example, if I searched for 'Jaws' it delivers results for Jaws, all the other Jaws movies and any other movie with Jaws in the name.

My question is, how do I filter through this return information, to find a perfect match with the right movie title and just show that info? I hope you can help and sure it is going to be some filtering logic. Thankyou! I am new to React so trying to learn.

const optionsParams = { method: 'GET', url: 'https://mdblist.p.rapidapi.com/', params: [], headers: { 'X-RapidAPI-Host': 'mdblist.p.rapidapi.com', 'X-RapidAPI-Key': '384177d302msh9d8e58dffccp1bfa57jsnf3cea9fef042', }, }; axios .request({ ...optionsParams, params: { s: ${movieData.title}} }) .then(function (response) { console.log(response.data); const traktid = response.data.search.traktid; const traktidOptions = { ...optionsParams, params: { t: ${traktid}` } }; axios.request(traktidOptions).then(function (response) {

        const streamingServices = response.data.streams;
        setStreamingState(streamingServices);
        //console.log(streamingState);
        console.log(response.data.streams)

        let temporaryArray = [];

        for (let i = 0; i < response.data.streams.length; i++){

          temporaryArray.push(response.data.streams[i].name)
          console.log(temporaryArray);

       }
     

       setStreamingState(streamingState => [...streamingState, `${temporaryArray}`])

        if (streamingState) {
          console.log(streamingState)
        } else return false;
      })
    })`
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Array methods are the perfect tool for iterating and organising array data.

In this case the Array.prototype.find() will help you look through your array and return a single item based on your criteria.

For example:

const yourArray = ["jaws", "not this jaws", "definitely not jaws"];

const found = yourArray.find(arrayItem => arrayItem === "jaws");

This is a simple example without objects, so you would just need to set the criteria based on an object property.

about 4 years ago · Juan Pablo Isaza 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