created fetch functions

This commit is contained in:
2021-11-04 13:56:21 -05:00
parent 5d167d884f
commit ed48714a4d
2 changed files with 19 additions and 8 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
{
"serviceRequest" : [
"serviceRequests" : [
{
"id": null,
"description": "some description",
+18 -7
View File
@@ -1,15 +1,25 @@
const API = "http://localhost:8088"
export const fetchRequests = () => {
return fetch(`${API}/requests`)
return fetch(`${API}/serviceRequests`)
.then(response => response.json())
.then(
(serviceRequests) => {
// Store the external state in application state
// Store the external state of in application state
applicationState.requests = serviceRequests
}
)
}
export const fetchJobTable = () => {
return fetch(`${API}/jobTable`)
.then(response => response.json())
.then(
(jobTable) => {
// Stores the external state of jobTable in application state
applicationState.requests = jobTable
}
)
}
export const getRequests = () => {
return database.serviceRequest.map(serviceRequest => ({...serviceRequest}))
@@ -26,9 +36,10 @@ export const getJobTable = () => {
// Need copies of permanent state set as empty arrays, matching the keys in your JSON file
const serviceRequest = []
const employeeTable = []
const jobTable = []
const requests = []
export const serviceRequest = []
export const employeeTable = []
export const jobTable = []
export const requests = []
const appState = []
// misc application state, if needed?
export const appState = []