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

224
Views
How to move ID from an API in one component to another componet to use that ID for another API

I will apologize in advance for incorrect lingo, just started to code in Nov.

I am using this API (https://www.themealdb.com/api/json/v1/1/filter.php?i=) to get idMeal, strMeal, strMealThumb from the objects, which is mapping over cards to populate different recipes. (Search Component)

I want the user to be able to click on it for them to go to another component that uses another API to populate the actual recipe( Recipe Component) with the id from the Search Component. www.themealdb.com/api/json/v1/1/lookup.php?i=${idMeal}

Unsure how to proceed with this. Was thinking about using a React Router Link to jump to the other component, and need to make the idMeal into state to transfer from Search into Recipe.

Should I use Redux, Context or something else?

    export default function Search() {
  const [isSearched, setSearched] = useState("");
  const [meals, setMeals] = useState([]);
  const [isId, setId] = useState("");

  const submitHandler = async (e) => {
    e.preventDefault();
    // console.log(isSearched);
    const res = await axios.get(
      `https://www.themealdb.com/api/json/v1/1/filter.php?i=${isSearched}`
    );
    setMeals(res.data.meals);
  };
  useEffect(() => {}, [meals]);

  return (
    <PageContainer>
      <ForkSpoonImg src={forkspoon} />
      <form onSubmit={submitHandler}>
        <h2 style={{ textAlign: "center" }}>Please Search an Ingredient</h2>
        <Input type="text" onInput={(e) => setSearched(e.target.value)}></Input>
        <Button type="submit">
          <SearchIcon />
        </Button>
      </form>
      <CardContainter>
        {meals.map(({ idMeal, strMeal, strMealThumb }, index) => {
          return (
            <Tag //<------- will change to Link, was just testing to see endpoint
              href={`www.themealdb.com/api/json/v1/1/lookup.php?i=${idMeal}`}
              key={index}
            >
              <Cards key={index} title={strMeal} url={strMealThumb} />
            </Tag>
          );
        })}
      </CardContainter>
    </PageContainer>
  );
}

Kindest Regards!

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