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

@ -1,15 +1,15 @@
import { AppRouterInstance } from "next/dist/shared/lib/app-router-context";
import { denyAccessToUser } from "../react/middlewares/views";
export const RequestBody = (method: string, data: any) => {
export const RequestBody = (method: string, data: any, next: any) => {
let HeadersConfig = new Headers({ "Content-Type": "application/json" });
let options: any = {
method: method,
headers: HeadersConfig,
redirect: "follow",
credentials: "include",
// Next.js
cache: 'no-store'
// Next.js
next: next,
};
if (data) {
options.body = JSON.stringify(data);
@ -17,7 +17,7 @@ export const RequestBody = (method: string, data: any) => {
return options;
};
export const RequestBodyForm = (method: string, data: any) => {
export const RequestBodyForm = (method: string, data: any, next: any) => {
let HeadersConfig = new Headers({});
let options: any = {
method: method,
@ -25,6 +25,8 @@ export const RequestBodyForm = (method: string, data: any) => {
redirect: "follow",
credentials: "include",
body: data,
// Next.js
next: next,
};
return options;
};