diff --git a/api/database.json b/api/database.json index 1996035..2e7b394 100644 --- a/api/database.json +++ b/api/database.json @@ -1,5 +1,5 @@ { - "serviceRequest" : [ + "serviceRequests" : [ { "id": null, "description": "some description", diff --git a/scripts/dataAccess.js b/scripts/dataAccess.js index 178b20a..25d700d 100644 --- a/scripts/dataAccess.js +++ b/scripts/dataAccess.js @@ -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 = [] \ No newline at end of file +// misc application state, if needed? +export const appState = [] \ No newline at end of file