What does <Generic Type> mean in this http.get? [closed]

Discussão em 'Angular' iniciado por Snorlax, Setembro 14, 2024.

  1. Snorlax

    Snorlax Guest

    getBooks(): Observable<Array<Books>> {

    return this.http
    .get<{ items: Books[] }>(
    'https://www.googleapis.com/books/v1/volumes?maxResults=5&orderBy=relevance&q=oliver%20sacks'
    )
    .pipe(map((books) => books.items || []));
    }
    export interface Books {
    id: string;
    volumeInfo: {
    title: string;
    authors: Array<string>;
    };

    }


    Trying to understand the TypeScript syntax here:

    .get<{ items: Books[] }>(


    Does this mean that first it gets the URL and does a map filter operator on it, then it's returning an object that only contains an items property with the interface Books[]?

    Continue reading...

Compartilhe esta Página