123456789101112131415161718192021222324252627282930313233343536 |
- const BASE_URL = "https://hiram.services/vacation-planner/api"
- export const getHealth = async () => {
- const res = await fetch(BASE_URL + "/");
- if (!res.ok) {
- throw new Error(res.statusText);
- }
- const { status } = await res.json();
- return status;
- }
- export const getAvailability = async () => {
- const res = await fetch(BASE_URL + "/availability");
- if (!res.ok) {
- throw new Error(res.statusText);
- }
- return await res.json();
- }
- export const setAvailability = async (name, availability) => {
- const res = await fetch(
- BASE_URL + "/availability",
- {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify({ name, availability }),
- }
- );
- if (!res.ok) {
- throw new Error(res.statusText);
- }
- }
|