{"size": 888, "ext": "js", "max_stars_repo_path": "src/utils/getLastFmData.js", "max_stars_repo_name": "Smittey/andysmith", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/utils/getLastFmData.js", "max_issues_repo_name": "Smittey/andysmith", "max_issues_repo_issues_event_min_datetime": "2019-01-02T02:01:45.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-26T22:35:57.000Z", "max_forks_repo_path": "src/utils/getLastFmData.js", "max_forks_repo_name": "Smittey/andysmith", "max_forks_repo_forks_event_min_datetime": "2016-02-02T14:30:28.000Z", "max_forks_repo_forks_event_max_datetime": "2016-02-02T14:30:28.000Z"}
{"max_stars_count": null, "max_issues_count": 11, "max_forks_count": 1, "avg_line_length": 22.7692307692, "max_line_length": 68, "alphanum_fraction": 0.6351351351}
export const getTopArtists = async ({
  username,
  apiKey,
}) => {
  const resource = await fetch('https://ws.audioscrobbler.com/2.0/?'
    + 'method=user.getTopArtists'
    + `&user=${username}`
    + '&period=3month'
    + `&api_key=${apiKey}`
    + '&limit=5'
    + '&format=json');

  const isError = !resource.ok;
  const response = await resource.json();

  if (isError) return Promise.reject(response);

  return Promise.resolve(response);
};

export const getCurrentlyPlaying = async ({
  username,
  apiKey,
}) => {
  const resource = await fetch('https://ws.audioscrobbler.com/2.0/?'
    + 'method=user.getrecenttracks'
    + `&user=${username}`
    + `&api_key=${apiKey}`
    + '&limit=1'
    + '&format=json');

  const isError = !resource.ok;
  const response = await resource.json();

  if (isError) return Promise.reject(response);

  return Promise.resolve(response);
};
