Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 27 additions & 24 deletions src/APIFunctions/LedSign.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import axios from 'axios';
import { ApiResponse } from './ApiResponses';
import { BASE_API_URL } from '../Enums';

Expand All @@ -12,15 +11,20 @@ import { BASE_API_URL } from '../Enums';
export async function healthCheck(officerName) {
let status = new ApiResponse();
const url = new URL('/api/LedSign/healthCheck', BASE_API_URL);
await axios
.get(url.href, { officerName })
.then(res => {
status.responseData = res.data;
})
.catch(err => {
status.responseData = err;
status.error = true;
try {
const response = await fetch(url.href, {
method: 'GET',
});

const data = await response.json().catch(() => null);
status.responseData = data;
if (!response.ok) {
status.error = true;
}
} catch (err) {
status.responseData = err;
status.error = true;
}
return status;
}

Expand All @@ -34,22 +38,21 @@ export async function healthCheck(officerName) {
export async function updateSignText(signData, token) {
let status = new ApiResponse();
const url = new URL('/api/LedSign/updateSignText', BASE_API_URL);
await axios
.post(
url.href,
signData,
{
headers: {
Authorization: `Bearer ${token}`
}
try {
const response = await fetch(url.href, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${token}`
},
)
.then(res => {
status.responseData = res.data;
})
.catch(err => {
status.responseData = err;
status.error = true;
body: JSON.stringify(signData)
});
if (!response.ok) {
status.error = true;
}
} catch (err) {
status.responseData = err;
status.error = true;
}
return status;
}