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

132
Views
ERROR TypeError: no se pueden leer las propiedades de indefinido (leyendo 'filtro') y console.log = indefinido

Estoy haciendo una solicitud de publicación, pongo la variable this.metodo=res, pero cuando pongo console.log(this.metodo) o trato de usar el filtro, devuelve undefined

 ngOnInit(): void { this.cartS.getTransporteMetodo(this.storeS.layout.emp.id).subscribe((res: any[]) => { this.metodo = res; }); console.log(this.metodo) filterMetodos(){ return this.metodo.filter( metodos => metodos.nome ); }

el json

 { "id": 1, "emp_id": 1, "nome": "Retirada na Loja", "tipo": "RETIRA", "subtipo": null, "latLng": [-25.45264, -49.26653], "vFreteMin": 0, "vFreteGratis": null, "periodos": [ { "id": 8, "transporte_id": 1, "ativo": 1, "periodo": "Comercial (das 8h \u00e0s 19h)", "corte": "17:00", "data": null, "week": [] } ]

},

 getTransporteMetodo(empId){ return this.http.post(environment.API_URL + 'transporte/getAll', { empId });

}

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

0

Mueva su registro dentro de la devolución de llamada de suscripción

 this.cartS.getTransporteMetodo(this.storeS.layout.emp.id).subscribe((res: any[]) => { this.metodo = res; console.log(this.metodo) });
about 4 years ago · Juan Pablo Isaza Report

0

La razón por la que no está definido es que el método es asnyc. Entonces intenta acceder a la variable antes de ser inicializada. Si desea filtrar la respuesta, coloque el filtro en el método de suscripción.

algo como esto:

 this.cartS.getTransporteMetodo(this.storeS.layout.emp.id).subscribe((res: any[]) => { this.metodo = res.filter(item=>nome); });
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!