Skip to content

Commit

Permalink
Merge pull request #60 from Etlas-SCU/Terms
Browse files Browse the repository at this point in the history
Terms
  • Loading branch information
AlaaaAhmed66 authored Jun 30, 2023
2 parents 8b955f4 + 7c3d5b9 commit 3b5bf5b
Show file tree
Hide file tree
Showing 6 changed files with 2,385 additions and 2,158 deletions.
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

78 changes: 75 additions & 3 deletions src/helpers/apiService.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ export async function Post(endpoint, body) {
});

var responseBody = null;

if (response.status !== 204) {
responseBody = response.data;
}
if (response.status>=200 && response.status<300) {

if (response.status >= 200 && response.status < 300) {
return {
isError: false,
body: responseBody,
Expand All @@ -32,6 +34,7 @@ export async function Post(endpoint, body) {
body: responseBody,
};
}

} catch (error) {
return {
isError: true,
Expand All @@ -47,10 +50,12 @@ export async function Patch(endpoint, body) {
});

var responseBody = null;

if (response.status !== 204) {
responseBody = response.data;
}
if (response.status>=200 && response.status<300) {

if (response.status >= 200 && response.status < 300) {
return {
isError: false,
body: responseBody,
Expand All @@ -61,10 +66,77 @@ export async function Patch(endpoint, body) {
body: responseBody,
};
}

} catch (error) {
return {
isError: true,
body: error,
};
}
}
}

export async function GET(endpoint) {
try {
const response = await axios.get(`${url}/${endpoint}`, {
headers: getHeaders(),
});

var responseBody = null;

if (response.status !== 204) {
responseBody = response.data;
}

if (response.status >= 200 && response.status < 300) {
return {
isError: false,
body: responseBody,
};
} else {
return {
isError: true,
body: responseBody,
};
}

} catch (error) {
return {
isError: true,
body: error,
};
}
}

export async function DELETE(endpoint, body) {
try {
const response = await axios.delete(`${url}/${endpoint}`, body, {
headers: getHeaders(),
});

var responseBody = null;

if (response.status !== 204) {
responseBody = response.data;
}

if (response.status >= 200 && response.status < 300) {
return {
isError: false,
body: responseBody,
};
} else {
return {
isError: true,
body: responseBody,
};
}

} catch (error) {
return {
isError: true,
body: error,
};
}
}


Loading

0 comments on commit 3b5bf5b

Please sign in to comment.