Skip to content

Commit

Permalink
update final code
Browse files Browse the repository at this point in the history
  • Loading branch information
Liz Hennessy authored and Liz Hennessy committed Apr 16, 2024
1 parent 74978b0 commit 527f60f
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/datasources/spotify-api.ts
Original file line number Diff line number Diff line change
@@ -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<PlaylistModel[]> {
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<PlaylistModel> {
Expand Down

0 comments on commit 527f60f

Please sign in to comment.