I think I have a misunderstanding on how works RxJS with an array when I receive it from an HTTP call.
For example I have:
public getNews(): Observable<News[]> {
return this.http.get<News[]>("/news");
}
And after I want to use a simple map on it:
this.newsService.getNews().pipe(map(news => {
return {
// DO SOMETHING HERE WITH NEWS
};
}));
The problem is the type of my param, Typescript told me its a array of News but it's inside a map so normally it has to of type News right?
I don't know If I'm clear, but if someone can explain me it would be great :)
news => news.map(singleNews => ({...singleNews, addedProperty: 1})). If you clarify what you're aiming for I'll post answerconst source = from([ { name: 'Joe', age: 30 }, { name: 'Frank', age: 20 }, { name: 'Ryan', age: 50 } ]); const example = source.pipe(map(({ name }) => name));LINK HERE