Skip to content

Commit

Permalink
build: return error when data load fails
Browse files Browse the repository at this point in the history
  • Loading branch information
jobson-almeida committed Feb 26, 2024
1 parent ab39274 commit cb2e8ef
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/app/(pages)/assessments/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import AssessmentsList from "../../components/assessments-list";

async function getAssessments() {
const response = await fetch('http://localhost:3000/api/assessments')
if (!response.ok) {
return new Error("failed to load assessments")
}
return response.json()
}

Expand Down
3 changes: 3 additions & 0 deletions src/app/(pages)/classrooms/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import ClassroomsList from "../../components/classroom-list";

async function getClassrooms() {
const response = await fetch('http://localhost:3000/api/classrooms')
if (!response.ok) {
return new Error("failed to load classrooms")
}
return response.json()
}

Expand Down
3 changes: 3 additions & 0 deletions src/app/(pages)/courses/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import CoursesList from "../../components/course-list";

async function getCourses() {
const response = await fetch('http://localhost:3000/api/courses')
if (!response.ok) {
return new Error("failed to load courses")
}
return response.json()
}

Expand Down
3 changes: 3 additions & 0 deletions src/app/(pages)/home/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import HomeList from "../../components/home-list";

async function getCourses() {
const response = await fetch('http://localhost:3000/api/courses')
if (!response.ok) {
return new Error("failed to load courses")
}
return response.json()
}

Expand Down
3 changes: 3 additions & 0 deletions src/app/(pages)/questions/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import QuestionsList from "../../components/questions-list";

async function getQuestions() {
const response = await fetch('http://localhost:3000/api/questions')
if (!response.ok) {
return new Error("failed to load questions")
}
return response.json()
}

Expand Down
3 changes: 3 additions & 0 deletions src/app/(pages)/students/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import StudentsList from "../../components/students-list"

async function getStudents() {
const response = await fetch('http://localhost:3000/api/students')
if (!response.ok) {
return new Error("failed to load students")
}
return response.json()
}

Expand Down
3 changes: 3 additions & 0 deletions src/app/(pages)/teachers/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import TeachersList from "../../components/teachers-list"

async function getTeachers() {
const response = await fetch('http://localhost:3000/api/teachers')
if (!response.ok) {
return new Error("failed to load teachers")
}
return response.json()
}

Expand Down

0 comments on commit cb2e8ef

Please sign in to comment.