Skip to content

Commit b108795

Browse files
committed
Query API in QuestionList
1 parent 58a14c4 commit b108795

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

peerprep/components/questionpage/QuestionCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const QuestionCard: React.FC<QuestionCardProps> = ({ question }) => {
3535
</span>
3636
</p>
3737
<p className="text-sm">
38-
Categories: <span>{question.category.join(", ")}</span>
38+
Categories: <span>{question.categories.join(", ")}</span>
3939
</p>
4040
</div>
4141

peerprep/components/questionpage/QuestionList.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@ const QuestionList: React.FC = () => {
2121
// make use of gateway.ts later
2222
const fetchQuestions = async () => {
2323
try {
24-
const response = await fetch("/data/dummyquestions.json");
24+
const response = await fetch(
25+
`${process.env.NEXT_PUBLIC_QUESTION_SERVICE}/questions`
26+
);
2527
const data: Question[] = await response.json();
2628
setQuestions(data);
2729

2830
// get all present categories in all qns
2931
const uniqueCategories = Array.from(
30-
new Set(data.flatMap((question) => question.category))
32+
new Set(data.flatMap((question) => question.categories))
3133
);
3234
setCategories(["all", ...uniqueCategories]);
3335
} catch (error) {
@@ -46,7 +48,7 @@ const QuestionList: React.FC = () => {
4648
difficulties[question.difficulty] === difficultyFilter;
4749
const matchesCategory =
4850
categoryFilter === categories[0] ||
49-
question.category.includes(categoryFilter);
51+
question.categories.includes(categoryFilter);
5052
const matchesSearch =
5153
searchFilter === "" ||
5254
question.title.toLowerCase().includes(searchFilter.toLowerCase());

peerprep/components/shared/Question.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ export interface Question {
22
id: number;
33
title: string;
44
description: string;
5-
category: string[];
5+
categories: string[];
66
difficulty: number;
77
test_cases: {
88
[key: string]: string;

question_api/log/question_api.log

Whitespace-only changes.

0 commit comments

Comments
 (0)