Check if error has response

This commit is contained in:
Ildar Kamalov 2019-02-18 19:36:24 +03:00
parent 954d923975
commit 1fc5f15aaa
1 changed files with 5 additions and 1 deletions

View File

@ -15,7 +15,11 @@ export default class Api {
return response.data; return response.data;
} catch (error) { } catch (error) {
console.error(error); console.error(error);
throw new Error(`${this.baseUrl}/${path} | ${error.response.data} | ${error.response.status}`); const errorPath = `${this.baseUrl}/${path}`;
if (error.response) {
throw new Error(`${errorPath} | ${error.response.data} | ${error.response.status}`);
}
throw new Error(`${errorPath} | ${error}`);
} }
} }