[Glitch] Add missing rejection handling for Promises

Port missing parts from 2c51bc0ca5 to glitch-soc
This commit is contained in:
Thibaut Girka
2019-02-10 21:28:29 +01:00
parent 6b2eefc7bf
commit a963ea67dd
8 changed files with 54 additions and 29 deletions

View File

@@ -1,4 +1,5 @@
import api from 'flavours/glitch/util/api';
import { showAlertForError } from './alerts';
export const LIST_FETCH_REQUEST = 'LIST_FETCH_REQUEST';
export const LIST_FETCH_SUCCESS = 'LIST_FETCH_SUCCESS';
@@ -239,7 +240,8 @@ export const fetchListSuggestions = q => (dispatch, getState) => {
};
api(getState).get('/api/v1/accounts/search', { params })
.then(({ data }) => dispatch(fetchListSuggestionsReady(q, data)));
.then(({ data }) => dispatch(fetchListSuggestionsReady(q, data)))
.catch(error => dispatch(showAlertForError(error)));
};
export const fetchListSuggestionsReady = (query, accounts) => ({