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

144
Views
Reactjs: TypeError: Cannot read properties of undefined (reading 'url')

I'm getting an undefined reading of url and other product.{items} when I reload the browser to run this piece of code.

 const location = useLocation();
    const id = location.pathname.split('/')[2];
    const [product, setProduct] = useState([]);

    useEffect(() => {
        const fetchProduct = async ()=>{
            try{
                const res = await commerce.products.retrieve(id);
                setProduct(res);
            }catch{}
        };
        fetchProduct();
    },[id]);


  return (
    <Container>
        <Wrapper>
            <ImgContainer>
               <Image src={product.image.url}/>
            </ImgContainer>
            <InfoContainer>
                <Title>{product.name}</Title>                
            </InfoContainer>
        </Wrapper>
    </Container>
  )
}
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!