Dropping xhr status as error descriptions
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
||||
@ -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({
|
||||
|
||||
Reference in New Issue
Block a user