Potential Jammming solution for those struggling with "Save to Spotify" functionality

I struggled extensively with the Jammming project, specifically the “Save to Spotify” button functionality. The accessToken kept being returned as undefined when I ran the .savePlaylist method. It turns out my problem was in the .getAccessToken method. It worked fine when triggered in .search(), but not in .savePlaylist().

The solution ended up being replacing window.location.href with window.location.hash in .getAccessToken. Here’s my code that fixed my problem:

const accessTokenMatch = window.location.hash.match(/access_token=([^&]*)/);
const expiresInMatch = window.location.hash.match(/expires_in=([^&]*)/);

Just wanted to put that out there, in case anyone is struggling like I was.