Created
July 28, 2020 09:02
-
-
Save alx8437/cb39cbd78ada53d78d94238a3c10a5b7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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