Skip to content

Instantly share code, notes, and snippets.

@alx8437
Created July 28, 2020 09:02
Show Gist options
  • Save alx8437/cb39cbd78ada53d78d94238a3c10a5b7 to your computer and use it in GitHub Desktop.
Save alx8437/cb39cbd78ada53d78d94238a3c10a5b7 to your computer and use it in GitHub Desktop.
// Create interfaces for type
interface Urls {
small: string;
regular: string;
}
export interface PictureDate {
id: string;
urls: Urls;
}
getPhotos(): Observable<PictureDate[]> { //Type for responce
const httpParam = new HttpParams()
.append('client_id', 'k_uAJlDjzQOJ1wE47nT83aMH6z-tj0_JsoTt9jzVbZI');
const url = `${environment.apiUrl}/photos`;
return this.http.get<PictureDate[]>(url, {params: httpParam}).pipe( //Type for get
map(p => {
return p.map(pic => {
return {
id: pic.id,
urls: pic.urls
};
});
})
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment