Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

432
Vistas
Type 'object' must have a 'Symbol.iterator' method that returns an iterator

data.technologies is an array and I would like to get the output of that array.

This is how the output of data.technologies looks like:

enter image description here

this.profileService.getEntities().subscribe(data => {
  for (const technology of data.technologies) {
    console.log(technology);
  }
});

The type of getEntities() is Observable<IprofileData>.

export interface IprofileData {  
  technologies: object;
}

TypeScript gives me the error:

TS2488: Type 'object' must have a 'Symbol.iterator' method that returns an iterator.

What am I doing wrong?

over 4 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

0

For future googlers:

This is also the error message returned if you forget to objectify your function inputs.

Example:

setCurrRowData(...currRowData, sort_order: num);

Fix:

setCurrRowData( { ...currRowData, sort_order: num } );
//              ^                                 ^
over 4 years ago · Santiago Trujillo Denunciar

0

Runtime structure is correct, it is an array, but the type says (from your comment) that it is just an object. Object has no iterator protocol, array has.

Example type which should fulfill the need:

type Data {
  ...// some other props
  technologies: string[] // change string into any type you have there
}
over 4 years ago · Santiago Trujillo Denunciar

0

Is data.technologies a function (you mentioned it "returned" an array)? If so, you simply need to call it like this:

this.profileService.getEntities().subscribe(data => {
    for (const technology of data.technologies()) {
        console.log(technology);
    }
});
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda