File tree Expand file tree Collapse file tree 2 files changed +41
-1
lines changed Expand file tree Collapse file tree 2 files changed +41
-1
lines changed Original file line number Diff line number Diff line change 11{
22 "index" : " Introduction" ,
3+ "techniques" : " Techniques" ,
34 "chapters" : " Chapters" ,
45 "verses" : " Verses" ,
56 "search" : " Search" ,
67 "juzs" : " Juzs" ,
78 "audio" : " Audio" ,
89 "resources" : " Resources" ,
910 "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