@@ -4,7 +4,7 @@ Fitch.js allows you to use a custom configuration for your requests. You just ne
44
55## Options
66
7- ** body**
7+ ### ** body** * (object) *
88
99Receives a json object, that is transformed to string by Fitch.js, before send the request.
1010
@@ -17,7 +17,32 @@ fitch.post(apiUrl, req)
1717 .then (data => console .log (data))
1818```
1919
20- ** params**
20+ ### ** dataType** * (string)*
21+
22+ Returns a parsed data of the type you need.
23+
24+ Valid options are: ` arrayBuffer ` , ` blob ` , ` formData ` , ` json ` and ` text ` .
25+
26+ * Default:* ` json ` .
27+
28+ See more at [ MDN] ( https://developer.mozilla.org/en-US/docs/Web/API/Body ) .
29+
30+ ``` js
31+ // Image file
32+ const config = { dataType: ' blob' }
33+
34+ fitch .get (' image.jpg' , config)
35+ .then ((imageBlob ) => {
36+ const objectURL = URL .createObjectURL (imageBlob)
37+ myImage .src = objectURL
38+ })
39+
40+ // Default: json.
41+ fitch .get (' file.json' )
42+ .then (data => console .log (data))
43+ ```
44+
45+ ### ** params** * (object)*
2146
2247You don't need to pass your URL parameters as string. Fitch.js allows you to pass the parameters inside a object:
2348
@@ -33,7 +58,7 @@ fitch.get(apiUrl, config)
3358 .then (data => console .log (data))
3459```
3560
36- ** raw**
61+ ### ** raw** * (boolean) *
3762
3863Returns the raw output of Fetch API, so you can work with headers and custom requests like files.
3964
@@ -46,8 +71,8 @@ fitch.get('image.jpg', { raw: true })
4671 console .log (' Network response was not ok.' );
4772 }
4873 })
49- .then (function (myBlob ) {
50- var objectURL = URL .createObjectURL (myBlob)
74+ .then ((myBlob ) => {
75+ const objectURL = URL .createObjectURL (myBlob)
5176 myImage .src = objectURL
5277 })
5378 .catch (fitch .error )
0 commit comments