Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

153
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!