Dropping xhr status as error descriptions

This commit is contained in:
James Barnsley
2017-12-02 14:32:34 +13:00
parent c2d694d0ac
commit 31f9461984
2 changed files with 10 additions and 3 deletions

View File

@ -30,6 +30,8 @@ const CoreMiddleware = (function(){
if (xhr_response.error && xhr_response.error.message){
var description = xhr_response.error.message;
}
} else if (action.data.xhr){
var description = action.data.xhr.status+' '+action.data.xhr.statusText;
} else {
var description = null;
}

View File

@ -58,12 +58,17 @@ const sendRequest = (dispatch, getState, endpoint, method = 'GET', data = false)
resolve(response)
},
(xhr, status, error) => {
dispatch(uiActions.stopLoading(loader_key))
dispatch(uiActions.stopLoading(loader_key));
// TODO: Rate limiting
if (xhr.status == 429){
alert("You hit the Spotify API rate limiter");
}
// TODO: Instead of allowing request to fail before renewing the token, once refreshed
// we should retry the original request(s)
if (xhr.responseJSON.error.message == 'The access token expired'){
dispatch(refreshToken(dispatch, getState))
if (xhr.responseJSON && xhr.responseJSON.error && xhr.responseJSON.error.message == 'The access token expired'){
dispatch(refreshToken(dispatch, getState));
}
reject({