Answer the question
In order to leave comments, you need to log in
How to load different entities in one Restapi request in Angular?
I understand with angular, in different lessons and office. documentation, but stuck with loading data from RESTAPI.
There is data, comment.ts :
export class comment {
id: number;
text: string;
author_id: number;
date_at: string;
author: Author;
}
export class Author {
id: number;
name: string;
}
getComments(limit, offset): Observable<Feed[]> {
const url = `${this.url}?limit=${limit}&offset=${offset}`;
return this.http.get<Comment[]>(url);
}
comments: Comment[] = [];
...
ngOnInit() {
this.commentService.getData(10, 0).subscribe((loadedData: Comment[]) => this.comment = loadedData);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question