Fixing add/remove track from library

This commit is contained in:
James Barnsley
2019-09-26 10:22:43 +12:00
parent f7808f954a
commit e17bf47fc5
7 changed files with 18 additions and 32 deletions

View File

@ -57,22 +57,11 @@ const request = (dispatch, getState, endpoint, method = 'GET', data = false, cac
dispatch(uiActions.stopLoading(loader_key));
// TODO: Rate limiting
if (response.status == 429) {
alert('You hit the Spotify API rate limiter');
if (response.status === 429) {
console.error('You hit the Spotify API rate limiter');
}
// Empty Response
if (response.status == 204) {
return Promise.resolve();
// Otherwise successful
} else if (response.status >= 200 && response.status < 400) {
return Promise.resolve(response.json());
// Not so successful
} else {
return Promise.reject(new Error(response.statusText))
}
return response.text().then((text) => (text ? JSON.parse(text) : {}));
}
fetch(url, config)
@ -80,7 +69,7 @@ const request = (dispatch, getState, endpoint, method = 'GET', data = false, cac
.then(data => {
// TODO: Instead of allowing request to fail before renewing the token, once refreshed
// we should retry the original request(s)
if (data && data.error && data.error.message == 'The access token expired') {
if (data && data.error && data.error.message === 'The access token expired') {
dispatch(refreshToken(dispatch, getState));
}

View File

@ -3,6 +3,8 @@ const blacklist = [
'jamesbarnsley.co.nz',
'following/contains',
'followers/contains',
'me/tracks',
'me/albums',
'refresh_spotify_token'
];
function inBlacklist(url) {