Show bad request message in ui

When a username already exists the api returns 400, this should be shown
to the user.
This commit is contained in:
Jannis Mattheis 2018-04-03 18:55:15 +02:00 committed by Jannis Mattheis
parent c35df51634
commit b5a224c9ae
1 changed files with 7 additions and 1 deletions

View File

@ -24,10 +24,16 @@ axios.interceptors.response.use(undefined, (error) => {
return Promise.reject(error);
}
if (error.response.status === 401) {
const status = error.response.status;
if (status === 401) {
tryAuthenticate().then(() => snack('Could not complete request.'));
}
if (status === 400) {
snack(error.response.data.error + ': ' + error.response.data.errorDescription);
}
return Promise.reject(error);
});