Advertisement
kklevi

az undorító getAll()

Nov 11th, 2024
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.   getMovies() {
  2.     return this.http
  3.       .get<{ data: { id: number; attributes: Movie & { director: { data: { attributes: { name: string } } } } }[] }>(
  4.         'https://movie-backend.hvb.k8s.nxdevel.hu/api/movies?populate=director'
  5.       )
  6.       .pipe(
  7.         map(response => {
  8.           return response.data.map(item => ({
  9.             id: item.id,
  10.             title: item.attributes.title,
  11.             releaseDate: item.attributes.releaseDate,
  12.             description: item.attributes.description,
  13.             createdAt: item.attributes.createdAt,
  14.             updatedAt: item.attributes.updatedAt,
  15.             publishedAt: item.attributes.publishedAt,
  16.             director: item.attributes.director.data.attributes.name
  17.           }));
  18.         })
  19.       );
  20.   }
  21.  
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement