react-ui-basics 0.0.203 → 0.0.204
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/HttpTools.d.ts +1 -0
- package/HttpTools.js +8 -6
- package/HttpTools.js.map +1 -1
- package/bundle.css +890 -890
- package/package.json +2 -2
- package/src/HttpTools.ts +9 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-ui-basics",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.204",
|
|
4
4
|
"description": "",
|
|
5
5
|
"module": "index.js",
|
|
6
6
|
"_main": "index.cjs.js",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"build": "./build.sh",
|
|
34
34
|
"postinstall": "",
|
|
35
35
|
"clean": "rm -rf build && mkdir build",
|
|
36
|
-
"dist": "npm
|
|
36
|
+
"dist": "NODE_OPTIONS=--openssl-legacy-provider npm-run-all clean build build-storybook && cd build && npm publish",
|
|
37
37
|
"storybook": "start-storybook -p 9009 -s public",
|
|
38
38
|
"build-storybook": "build-storybook -c .storybook -o docs"
|
|
39
39
|
},
|
package/src/HttpTools.ts
CHANGED
|
@@ -22,6 +22,7 @@ export class FetchOptions {
|
|
|
22
22
|
async?: boolean = true
|
|
23
23
|
withCredentials?: boolean = true
|
|
24
24
|
timeout?: number
|
|
25
|
+
responseType?: "arraybuffer" | "text" | "json" | "blob" | "document" = "json"
|
|
25
26
|
onTimeout?: ((ev: ProgressEvent) => any)
|
|
26
27
|
onSuccess?: ((t: any) => void)
|
|
27
28
|
onError?: ((e: any, status: number) => void)
|
|
@@ -104,21 +105,23 @@ export const fetch = <T>(url, options: FetchOptions = DEFAULT_OPTIONS) => {
|
|
|
104
105
|
request.onprogress = onProgress;
|
|
105
106
|
}
|
|
106
107
|
|
|
108
|
+
request.responseType = options.responseType
|
|
109
|
+
|
|
107
110
|
request.onload = () => {
|
|
108
|
-
const
|
|
111
|
+
const response = request.response;
|
|
109
112
|
const status = request.status;
|
|
110
113
|
if (status >= 200 && status < 400) {
|
|
111
114
|
try {
|
|
112
|
-
orNoop(success)(
|
|
115
|
+
orNoop(success)(response);
|
|
113
116
|
} catch (e) {
|
|
114
|
-
const message = `Unexpected exception while processing response for ${method} ${url}, status: ${status}, response: '${
|
|
117
|
+
const message = `Unexpected exception while processing response for ${method} ${url}, status: ${status}, response: '${response}', exception:`;
|
|
115
118
|
console.log(message, e)
|
|
116
|
-
onError(new FetchError(message, status,
|
|
119
|
+
onError(new FetchError(message, status, response))
|
|
117
120
|
}
|
|
118
121
|
} else {
|
|
119
|
-
const message = `Not ok response for ${method} ${url}, status: ${status}, response: '${
|
|
122
|
+
const message = `Not ok response for ${method} ${url}, status: ${status}, response: '${response}'`;
|
|
120
123
|
console.log(message);
|
|
121
|
-
onError(new FetchError(message, status,
|
|
124
|
+
onError(new FetchError(message, status, response))
|
|
122
125
|
}
|
|
123
126
|
};
|
|
124
127
|
|