File tree 2 files changed +41
-1
lines changed
2 files changed +41
-1
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"index" : " Introduction" ,
3
+ "techniques" : " Techniques" ,
3
4
"chapters" : " Chapters" ,
4
5
"verses" : " Verses" ,
5
6
"search" : " Search" ,
6
7
"juzs" : " Juzs" ,
7
8
"audio" : " Audio" ,
8
9
"resources" : " Resources" ,
9
10
"utils" : " Utilities"
10
- }
11
+ }
Original file line number Diff line number Diff line change
1
+ ## Custom fetcher
2
+
3
+ By default, all functions that interact with the [ Quran.com API] ( https://quran.api-docs.io/v4 ) use the global ` fetch ` function.
4
+
5
+ You can override this by passing a custom fetcher (as ` fetchFn ` ) to the options object of any method.
6
+
7
+ import { Callout } from ' nextra-theme-docs' ;
8
+
9
+ <Callout >
10
+ Note that the ` fetchFn ` accepts a string url and must return a promise with
11
+ the JSON response.
12
+ </Callout >
13
+
14
+ ### Examples
15
+
16
+ #### Axios
17
+
18
+ ``` ts
19
+ import axios from ' axios' ;
20
+
21
+ const chapters = await quran .v4 .chapters .findAll ({
22
+ fetchFn : (url ) => axios .get (url ).then ((res ) => res .data ),
23
+ });
24
+ ```
25
+
26
+ ---
27
+
28
+ #### Node-fetch
29
+
30
+ ``` ts
31
+ import fetch from ' node-fetch' ;
32
+
33
+ const chapters = await quran .v4 .chapters .findAll ({
34
+ fetchFn : async (url ) => {
35
+ const response = await fetch (url );
36
+ return response .json ();
37
+ },
38
+ });
39
+ ```
You can’t perform that action at this time.
0 commit comments