Show toast on failed request

This commit is contained in:
Ildar Kamalov 2018-09-14 15:37:35 +03:00
parent 9258fada47
commit 828bb40084
11 changed files with 230 additions and 32 deletions
client/src/api

View file

@ -6,12 +6,16 @@ export default class Api {
baseUrl = 'control';
async makeRequest(path, method = 'POST', config) {
const response = await axios({
url: `${this.baseUrl}/${path}`,
method,
...config,
});
return response.data;
try {
const response = await axios({
url: `${this.baseUrl}/${path}`,
method,
...config,
});
return response.data;
} catch (error) {
throw new Error(`${this.baseUrl}/${path} | ${error.response.data} | ${error.response.status}`);
}
}
// Global methods