File tree Expand file tree Collapse file tree 2 files changed +16
-14
lines changed Expand file tree Collapse file tree 2 files changed +16
-14
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ const filesToCache = [
12
12
"/static/js/main.chunk.js" ,
13
13
"/static/js/bundle.js" ,
14
14
"/static/js/1.chunk.js" ,
15
+ "/static/js/0.chunk.js" ,
15
16
16
17
"/web-fonts/css/all.min.css" ,
17
18
Original file line number Diff line number Diff line change 1
- import { Quiz , QuestionType } from "../types/quiz_types" ;
1
+ import { Quiz , QuestionType } from "../types/quiz_types"
2
2
3
3
// Shuffle Answers functions
4
- const shuffleAnswers = ( array : any [ ] ) =>
5
- [ ...array ] . sort ( ( ) => Math . random ( ) - 0.5 ) ;
4
+ const shuffleAnswers = ( array : any [ ] ) => [ ...array ] . sort ( ( ) => Math . random ( ) - 0.5 )
6
5
7
6
// Get Data from API
8
- export const getQuizDetails = async (
9
- totalQuestions : number ,
10
- category : number ,
11
- level : string
12
- ) : Promise < QuestionType [ ] > => {
7
+ export const getQuizDetails = async ( totalQuestions : number , category : number , level : string ) : Promise < QuestionType [ ] > => {
8
+
13
9
const response = await fetch (
14
10
`https://opentdb.com/api.php?amount=${ totalQuestions } &category=${ category } &difficulty=${ level } &type=multiple`
15
- ) ;
16
- let { results } = await response . json ( ) ;
11
+ )
12
+
13
+
14
+ console . log ( response )
15
+ let { results } = await response . json ( )
16
+
17
17
const quiz : QuestionType [ ] = results . map ( ( questionObj : Quiz ) => {
18
18
return {
19
19
question : questionObj . question ,
20
20
answer : questionObj . correct_answer ,
21
21
options : shuffleAnswers (
22
22
questionObj . incorrect_answers . concat ( questionObj . correct_answer )
23
23
) ,
24
- } ;
25
- } ) ;
26
- return quiz ;
27
- } ;
24
+ }
25
+ } )
26
+
27
+ return quiz
28
+ }
You can’t perform that action at this time.
0 commit comments