Skip to content
This repository has been archived by the owner on Jun 1, 2024. It is now read-only.

Commit

Permalink
Remove global variable
Browse files Browse the repository at this point in the history
  • Loading branch information
Adamv27 committed Apr 22, 2024
1 parent ac63c6d commit 0790976
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions api.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ function assertResponse(response) {
throw new Error(`${response.status}: ${response.statusText}`);
}

const API = `${process.env.NEXT_PUBLIC_BACKEND_HOST}/api`;

async function getDjangoToken() {
const session = await getSession();
Expand All @@ -26,6 +25,9 @@ async function makeRequest(url, method="GET", body=null, headers={}) {
'Content-Type': 'application/json',
}

const API = `${process.env.NEXT_PUBLIC_BACKEND_HOST}/api`;
url = `${API}/${url}`

const response = await fetch(url, {
method,
headers: requestHeaders,
Expand All @@ -40,14 +42,14 @@ async function makeRequest(url, method="GET", body=null, headers={}) {


export async function getEnrollments() {
const url = `${API}/enrollments/`;
const url = "enrollments/";
const json = await makeRequest(url);
return json;
}


export async function getStudentAssignments(slug) {
const url = `${API}/courses/${slug}/assignments/`;
const url = `courses/${slug}/assignments/`;
const json = await makeRequest(url);
return json
}
Expand Down

0 comments on commit 0790976

Please sign in to comment.