Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/development' into feature/comple…
Browse files Browse the repository at this point in the history
…te-d2-relationship-contraints
  • Loading branch information
SferaDev committed May 11, 2021
2 parents 69e6af4 + e82464d commit 925efaa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@eyeseetea/d2-api",
"description": "Typed wrapper over DHIS2 API",
"version": "1.8.2",
"version": "1.8.3",
"license": "GPL-3.0",
"author": "EyeSeeTea team",
"repository": {
Expand Down
8 changes: 6 additions & 2 deletions src/api/dataStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,17 @@ export class DataStore {
}
}

function validate2xx(status: number): boolean {
return (status >= 200 && status < 300);
}

function validate404(status: number): boolean {
return (status >= 200 && status < 300) || status === 404;
return validate2xx(status) || status === 404;
}

function validateResponse(response: HttpClientResponse<HttpResponse<unknown>>): undefined {
const { data } = response;
if (response.status === 200 && data.status === "OK") {
if (validate2xx(response.status) && data.status === "OK") {
return;
} else {
throw new Error(data.message || "Invalid response from server");
Expand Down

0 comments on commit 925efaa

Please sign in to comment.