@@ -6,6 +6,7 @@ const questions: { [key: string]: Question } = {
6
6
"difficulty" : 2 ,
7
7
"title" : "Two Sum" ,
8
8
"description" : "Given an array of integers, return indices of the two numbers such that they add up to a specific target." ,
9
+ "categories" : [ "Hash Table" , "Array" ] ,
9
10
"test_cases" : {
10
11
"[2, 7, 11, 15], 9" : "[0, 1]" ,
11
12
"[3, 2, 4], 6" : "[1, 2]" ,
@@ -17,6 +18,7 @@ const questions: { [key: string]: Question } = {
17
18
"difficulty" : 1 ,
18
19
"title" : "Reverse Integer" ,
19
20
"description" : "Given a 32-bit signed integer, reverse digits of an integer." ,
21
+ "categories" : [ "Math" ] ,
20
22
"test_cases" : {
21
23
"123" : "321" ,
22
24
"1" : "1" ,
@@ -36,13 +38,13 @@ export async function fetchQuestion(questionId: string): Promise<Question|Status
36
38
const response = await fetch ( `${ process . env . NEXT_PUBLIC_QUESTION_SERVICE } /questions/solve/${ questionId } ` ) ;
37
39
if ( ! response . ok ) {
38
40
return {
39
- ... ( await response . json ( ) ) ,
40
- status : response . status
41
+ error : await response . text ( ) ,
42
+ status : response . status
41
43
} ;
42
44
}
43
45
return await response . json ( ) as Question ;
44
46
} catch ( err : any ) {
45
- return { error : err . message , status : 0 } ;
47
+ return { error : err . message , status : 400 } ;
46
48
}
47
49
}
48
50
0 commit comments