1
0
mirror of https://github.com/sasjs/adapter.git synced 2026-01-09 05:20:05 +00:00

fix: raising error with details we get from server

This commit is contained in:
Saad Jutt
2022-03-02 20:25:56 +05:00
parent 82e061a09c
commit 2e843e3f36
2 changed files with 18 additions and 4 deletions

View File

@@ -557,8 +557,18 @@ export class RequestClient implements HttpClient {
}
export const throwIfError = (response: AxiosResponse) => {
if (response.status === 401) {
throw new LoginRequiredError()
switch (response.status) {
case 400:
if (typeof response.data === 'object') {
throw new LoginRequiredError(response.data)
}
break
case 401:
if (typeof response.data === 'object') {
throw new LoginRequiredError(response.data)
} else {
throw new LoginRequiredError()
}
}
if (response.data?.entityID?.includes('login')) {