-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added method for checking pending appointment request
- Loading branch information
Showing
2 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
"use server"; | ||
|
||
import { getSessionToken } from "../sessions/sessionUtils"; | ||
import getBaseUrl from "@utils/getBaseUrl"; | ||
|
||
export default async function pendingAppointmentsRequest(hospital_id: string) { | ||
const session = await getSessionToken(); | ||
const serverUrl = getBaseUrl(); | ||
|
||
const headers = { | ||
Authorization: `Bearer ${session}`, | ||
}; | ||
try { | ||
const res = await fetch(`${serverUrl}/api/patient/appointment/pending`, { | ||
method: "POST", | ||
body: JSON.stringify(hospital_id), | ||
headers, | ||
}); | ||
|
||
if (!res.ok) { | ||
throw new Error( | ||
`fetching pending appointment request : ${res.statusText}` | ||
); | ||
} | ||
|
||
const data = await res.json(); | ||
|
||
return data; | ||
} catch (error) { | ||
console.error("An error occurred while :", error); | ||
} | ||
} |