Skip to content

Commit

Permalink
files renamed
Browse files Browse the repository at this point in the history
  • Loading branch information
Prakhar-commits committed Nov 1, 2023
1 parent 3804443 commit e1cf7dd
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/utils/FormInputHandling.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { RowType } from "@/types/types";
import { instance } from "./RootClient";

// get data from the db
async function getData(currentPage: number, limit: number) {
const { data } = await instance.get(
`api/session?session_id_is_null=true&offset=${currentPage}&limit=${limit}`
);
return data;
}

// post data to the server
async function postFormData(formData: RowType) {
const currentDate = new Date().toLocaleDateString();

const res = await instance.post("/quiz", {
dateCreated: currentDate,
...formData,
});

return res;
}

export { getData, postFormData };
6 changes: 6 additions & 0 deletions src/utils/RootClient.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import axios from "axios";

export const instance = axios.create({
baseURL: process.env.NEXT_PUBLIC_DB_URL,
headers: { Authorization: "Bearer " + process.env.NEXT_PUBLIC_BEARER_TOKEN },
});

0 comments on commit e1cf7dd

Please sign in to comment.