feat: reformat utility req functions to use next

This commit is contained in:
swve 2023-05-19 09:08:02 +00:00
parent 1f6020efc0
commit bb0f9166f9
14 changed files with 43 additions and 41 deletions

View file

@ -6,15 +6,15 @@ import { RequestBody, RequestBodyForm, errorHandling } from "@services/utils/ts/
GET requests are called from the frontend using SWR (https://swr.vercel.app/)
*/
export async function getOrgCourses(org_id: number) {
const result: any = await fetch(`${getAPIUrl()}courses/org_slug/${org_id}/page/1/limit/10`, RequestBody("GET", null));
export async function getOrgCourses(org_id: number, next: any) {
const result: any = await fetch(`${getAPIUrl()}courses/org_slug/${org_id}/page/1/limit/10`, RequestBody("GET", null, next));
const res = await errorHandling(result);
return res;
}
export async function getCourse(course_id: string) {
const result: any = await fetch(`${getAPIUrl()}courses/${course_id}`, RequestBody("GET", null));
export async function getCourse(course_id: string, next: any) {
const result: any = await fetch(`${getAPIUrl()}courses/${course_id}`, RequestBody("GET", null, next));
const res = await errorHandling(result);
return res;
}
@ -28,13 +28,13 @@ export async function createNewCourse(org_id: string, course_body: any, thumbnai
formData.append("mini_description", "course_body.mini_description");
formData.append("public", "true");
const result = await fetch(`${getAPIUrl()}courses/?org_id=${org_id}`, RequestBodyForm("POST", formData));
const result = await fetch(`${getAPIUrl()}courses/?org_id=${org_id}`, RequestBodyForm("POST", formData, null));
const res = await errorHandling(result);
return res;
}
export async function deleteCourseFromBackend(course_id: any) {
const result: any = await fetch(`${getAPIUrl()}courses/${course_id}`, RequestBody("DELETE", null));
const result: any = await fetch(`${getAPIUrl()}courses/${course_id}`, RequestBody("DELETE", null, null));
const res = await errorHandling(result);
return res;
}