Issue
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:
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?
Solution
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
}
Answered By - Maciej Sikora

0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.