From 527f60f44c1e08eb5f4359b655ca72d378a69547 Mon Sep 17 00:00:00 2001 From: Liz Hennessy Date: Mon, 15 Apr 2024 20:45:10 -0600 Subject: [PATCH] update final code --- src/datasources/spotify-api.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/datasources/spotify-api.ts b/src/datasources/spotify-api.ts index 4dde855..650b030 100644 --- a/src/datasources/spotify-api.ts +++ b/src/datasources/spotify-api.ts @@ -1,12 +1,18 @@ import { RESTDataSource } from "@apollo/datasource-rest"; +import { Playlist } from "../types" import { PlaylistModel, SnapshotOrError } from '../models' export class SpotifyAPI extends RESTDataSource { baseURL = "https://spotify-demo-api-fe224840a08c.herokuapp.com/v1/"; - + async getFeaturedPlaylists(): Promise { - const { playlists: { items } } : { playlists: { items: [] }} = await this.get("browse/featured-playlists"); - return items; + const response = await this.get<{ + playlists: { + items: PlaylistModel[]; + }; + }>("browse/featured-playlists"); + + return response?.playlists?.items ?? []; } getPlaylist(playlistId: string): Promise {