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

226
Views
TypeError no detectado: no se pueden leer las propiedades de objetos JS no definidos (leyendo 'nombre de la empresa')

Tengo un problema cuando intento mapear mis datos. Quiero un nombre de empresa alcance en proveedor en productos. ¿Cómo puedo arreglarlo?

 {products.map((repo) => ( <div style={{ backgroundColor: "#c1d3d4", marginTop: 50, display: "flex", flexDirection: "column", minWidth: 1000, paddingLeft: 50, marginLeft: 400, paddingRight: 30, paddingBottom: 12, borderRadius: 15, }} span={24} > <p style={{ flex: 1, fontWeight: "bold", fontSize: 26 }}> {repo.name} </p> <p style={{ fontWeight: "bold", fontSize: 14 }}>{repo.supplier.companyName}</p> <p style={{ fontWeight: "bold", fontSize: 14 }}> {repo.quantityPerUnit} </p> <div style={{ display: "flex", flexDirection: "row", justifyContent: "space-between", alignContent: "flex-end", }} > <p style={{ fontSize: 20, fontWeight: "800", color: "green", alignSelf: "flex-end", }} > {repo.unitPrice.toFixed(2)} </p> <Button type="primary" onClick={() => AddCart(repo)}> Sepete Ekle </Button> </div> </div> ))}

este es un error de mensaje de error

esto es datos:

https://northwind.vercel.app/api/products

editar:

@Tim Roberts encontró la solución. Solo algunos elementos tienen proveedor por lo que otros no lo tienen. Tomé el mensaje de error cuando intento el mapa. Entiendo ahora.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Creo que el error se debe a que en algunos datos de la api no existe el accesorio del proveedor.

Tu codigo

 <p style={{ fontWeight: "bold", fontSize: 14 }}>{repo.supplier.companyName}</p>

Solución posible

 <p style={{ fontWeight: "bold", fontSize: 14 }}>{repo.supplier && repo.supplier.companyName}</p>
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!