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