Skip to content

Commit

Permalink
fixing error in Spotify API song search: filtering out nulled items
Browse files Browse the repository at this point in the history
  • Loading branch information
DerLev committed Apr 22, 2024
1 parent 4414342 commit 64b879e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion functions/src/helpers/spotifyConverters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,15 @@ export const convertStationPlaylist = async (
);
}

const filterNulledItems = result.tracks.items
.filter((item) => item !== null);

const songsCollection = db.collection("songs")
.withConverter(firestoreConverter<SongsCollection>());

/* Retry track search -> get track by Spotify URI */
const trackByURI = await songsCollection
.where("spotifyTrackUri", "==", result.tracks.items[0].uri)
.where("spotifyTrackUri", "==", filterNulledItems[0].uri)
.limit(1).get();

/* If track was found... */
Expand Down

0 comments on commit 64b879e

Please sign in to comment.