Skip to content

Commit

Permalink
added environment variable
Browse files Browse the repository at this point in the history
  • Loading branch information
Prakhar-commits committed Sep 4, 2023
1 parent 078c3d3 commit 29ec0e7
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 5 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
NEXT_PUBLIC_BACKEND_URL = http://localhost:3000
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,5 @@ yarn-error.log*
next-env.d.ts

venv

.env.local
93 changes: 93 additions & 0 deletions db.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,99 @@
"synced": true
},
"id": 4
},
{
"student": {
"testTakers": "1500",
"program": "Delhi Students",
"batch": "DL-12-Alpha-med-23",
"grade": "11",
"course": "Certification",
"stream": "Physics"
},
"test": {
"name": "canem",
"type": "omr_assessment",
"format": "evaluation_test",
"purpose": "reshuffling_test",
"platform": "Quiz",
"markingScheme": "1,0",
"optionalLimit": "jee"
},
"timeline": {
"startDate": "2023-09-25",
"endDate": "2023-09-30",
"startTime": "17:38",
"endTime": "19:38",
"reportSchedule": "afa",
"reportLink": "ss",
"isEnabled": false,
"sessionType": "standard",
"synced": false
},
"id": 5
},
{
"student": {
"testTakers": "54654",
"program": "Haryana Students",
"batch": "DL-12-Alpha-Eng-23",
"grade": "10",
"course": "NEET",
"stream": "Medical"
},
"test": {
"name": "sfaa",
"type": "assessment",
"format": "major_test",
"purpose": "weekly_test",
"platform": "Quiz",
"markingScheme": "1,0",
"optionalLimit": "na"
},
"timeline": {
"startDate": "2023-09-19",
"endDate": "2023-09-23",
"startTime": "16:14",
"endTime": "19:14",
"reportSchedule": "FFFF",
"reportLink": "FFFFH",
"isEnabled": false,
"sessionType": "infinite",
"synced": true
},
"id": 6
},
{
"student": {
"testTakers": "8989",
"program": "Himachal Students",
"batch": "DL-12-Photon-Eng-23",
"grade": "10",
"course": "Catalyst",
"stream": "Maths"
},
"test": {
"name": "foo",
"type": "homework",
"format": "major_test",
"purpose": "endline",
"platform": "Quiz",
"markingScheme": "1,0",
"optionalLimit": "neet"
},
"timeline": {
"startDate": "2023-09-11",
"endDate": "2023-09-15",
"startTime": "17:24",
"endTime": "19:24",
"reportSchedule": "Hello",
"reportLink": "hellosa",
"isEnabled": true,
"sessionType": "standard",
"synced": true
},
"id": 7
}
]
}
6 changes: 3 additions & 3 deletions src/utils/api.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { RowType } from "@/types/types";
import { axios_ } from "./axios";
import { instance } from "./axios";

// get data from the db
async function getData() {
const { data } = await axios_.get("/quiz");
const { data } = await instance.get("/quiz");

return data;
}
Expand All @@ -12,7 +12,7 @@ async function getData() {
async function postFormData(formData: RowType) {
console.log(formData);

const res = await axios_.post("/quiz", formData);
const res = await instance.post("/quiz", formData);
console.log(res.data);

return res;
Expand Down
8 changes: 6 additions & 2 deletions src/utils/axios.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import axios from "axios";

export const axios_ = axios.create({
baseURL: "http://localhost:3001",
// export const axios_ = axios.create({
// baseURL: "http://localhost:3001",
// });

export const instance = axios.create({
baseURL: process.env.NEXT_PUBLIC_BACKEND_URL,
});

0 comments on commit 29ec0e7

Please sign in to comment.