search(term) {
    accessToken = Spotify.getAccessToken();
    const regexCheck = /[-[\]{}()*+?.,\\^$|#\s]/g;
    return fetch(
      `https://api.spotify.com/v1/search?type=track&q=${term.replace(
        regexCheck,
        ''
      )}`,
      {
        headers: {
          Authorization: `Bearer ${accessToken}`,
        },
      }
    )
      .then((response) => {
        return response.json();
      })
      .then((jsonResponse) => {
        if (jsonResponse.tracks) {
          return jsonResponse.tracks.items.map((track) => ({
            id: track.id,
            name: track.name,
            artist: track.artists[0].name,
            album: track.album.name,
            uri: track.uri,
          }));
        } else {
          return [];
        }
      });
  }
//Searches through the Spotify API to return relevant track information.
Searches through the Spotify API to return relevant track information.
Searches through the Spotify API to return relevant track information .
search(term) {
    accessToken = Spotify.getAccessToken();
    const regexCheck = /[-[\]{}()*+?.,\\^$|#\s]/g;
    return fetch(
      `https://api.spotify.com/v1/search?type=track&q=${term.replace(
        regexCheck,
        ''
      )}`,
      {
        headers: {
          Authorization: `Bearer ${accessToken}`,
        },
      }
    )
      .then((response) => {
        return response.json();
      })
      .then((jsonResponse) => {
        if (jsonResponse.tracks) {
          return jsonResponse.tracks.items.map((track) => ({
            id: track.id,
            name: track.name,
            artist: track.artists[0].name,
            album: track.album.name,
            uri: track.uri,
          }));
        } else {
          return [];
        }
      });
  }
search ( term ) { accessToken = Spotify . getAccessToken ( ) ; const regexCheck = / [-[\]{}()*+?.,\\^$|#\s] / g ; return fetch ( ` ${ term . replace ( regexCheck , '' ) } ` , { headers : { Authorization : ` ${ accessToken } ` , } , } ) . then ( ( response ) => { return response . json ( ) ; } ) . then ( ( jsonResponse ) => { if ( jsonResponse . tracks ) { return jsonResponse . tracks . items . map ( ( track ) => ( { id : track . id , name : track . name , artist : track . artists [ 0 ] . name , album : track . album . name , uri : track . uri , } ) ) ; } else { return [ ] ; } } ) ; }
Searches through the Spotify API to return relevant track information.
Searches through the Spotify API to return relevant track information .