diff --git a/src/api/apiHandlers.js b/src/api/apiHandlers.js deleted file mode 100644 index 4991288..0000000 --- a/src/api/apiHandlers.js +++ /dev/null @@ -1,95 +0,0 @@ -/* eslint-disable no-empty-pattern */ -const API_URL = "http://localhost:80/api/v1"; // Replace with env variable - -const defaultOptions = ({ headers, options }) => ({ - headers: { - "Content-type": "application/json", - Authorization: `JWT ${123}`, // Add JWT token here; // If Using Cookies for session authentication you can remove this and add "Cookie" header - ...headers, - }, - ...options, -}); - -export const apiGet = async ({ path, headers: {}, options: {} }) => { - return fetch(API_URL + path, defaultOptions(headers, options)) - .then((raw) => raw.json()) - .then((res) => { - // TODO: Add logic to handle API errors - - return res; - }) - .catch((err) => { - console.log(err); - }); -}; - -export const apiPost = async ({ path, body: {}, headers: {}, options: {} }) => { - const reqOptions = defaultOptions({ - headers, - options: { - method: "POST", - body: body, - ...options, - }, - }); - - return fetch(API_URL + path, reqOptions) - .then((raw) => raw.json()) - .then((res) => { - // TODO: Add logic to handle API errors - - return res; - }) - .catch((err) => { - console.log(err); - }); -}; - -export const apiPut = async ({ path, body: {}, headers: {}, options: {} }) => { - const reqOptions = defaultOptions({ - headers, - options: { - method: "PUT", - body: body, - ...options, - }, - }); - - return fetch(API_URL + path, reqOptions) - .then((raw) => raw.json()) - .then((res) => { - // TODO: Add logic to handle API errors - - return res; - }) - .catch((err) => { - console.log(err); - }); -}; - -export const apiDelete = async ({ - path, - body: {}, - headers: {}, - options: {}, -}) => { - const reqOptions = defaultOptions({ - headers, - options: { - method: "DELETE", - body: body, - ...options, - }, - }); - - return fetch(API_URL + path, reqOptions) - .then((raw) => raw.json()) - .then((res) => { - // TODO: Add logic to handle API errors - - return res; - }) - .catch((err) => { - console.log(err); - }); -}; diff --git a/src/api/providerAPI.js b/src/api/providerAPI.js deleted file mode 100644 index 052e930..0000000 --- a/src/api/providerAPI.js +++ /dev/null @@ -1,12 +0,0 @@ -import { apiGet } from "./apiHandlers"; - -// Example file with requests to the Provider API -// Make one file for each service that this app is accessing - -const PROVIDER_API_ROUTE = "/provider"; - -export const getProvider = async () => { - const provider = await apiGet({ path: `${PROVIDER_API_ROUTE}/` }); - - return provider; -};