@faasjs/react 0.0.2-beta.296 → 0.0.2-beta.297
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/lib/index.js +10 -9
- package/package.json +2 -2
package/lib/index.js
CHANGED
|
@@ -10,7 +10,10 @@
|
|
|
10
10
|
async function faas(action, params) {
|
|
11
11
|
if (onError)
|
|
12
12
|
return client.action(action, params)
|
|
13
|
-
.catch(
|
|
13
|
+
.catch(async (res) => {
|
|
14
|
+
await onError(action, params)(res);
|
|
15
|
+
return Promise.reject(res);
|
|
16
|
+
});
|
|
14
17
|
return client.action(action, params);
|
|
15
18
|
}
|
|
16
19
|
function useFaas(action, defaultParams) {
|
|
@@ -30,23 +33,21 @@
|
|
|
30
33
|
const request = client.action(action, params);
|
|
31
34
|
setPromise(request);
|
|
32
35
|
request
|
|
33
|
-
.then(r =>
|
|
34
|
-
setData(r === null || r === void 0 ? void 0 : r.data);
|
|
35
|
-
})
|
|
36
|
+
.then(r => setData(r.data))
|
|
36
37
|
.catch(async (e) => {
|
|
37
38
|
if (onError)
|
|
38
39
|
try {
|
|
39
|
-
|
|
40
|
+
await onError(action, params)(e);
|
|
40
41
|
}
|
|
41
42
|
catch (error) {
|
|
42
43
|
setError(error);
|
|
43
44
|
}
|
|
44
|
-
|
|
45
|
+
else
|
|
46
|
+
setError(e);
|
|
47
|
+
return Promise.reject(e);
|
|
45
48
|
})
|
|
46
49
|
.finally(() => setLoading(false));
|
|
47
|
-
return () =>
|
|
48
|
-
setLoading(false);
|
|
49
|
-
};
|
|
50
|
+
return () => setLoading(false);
|
|
50
51
|
}, [
|
|
51
52
|
action,
|
|
52
53
|
JSON.stringify(params),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faasjs/react",
|
|
3
|
-
"version": "0.0.2-beta.
|
|
3
|
+
"version": "0.0.2-beta.297",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/react/src/index.d.ts",
|
|
@@ -27,5 +27,5 @@
|
|
|
27
27
|
"rollup-plugin-typescript2": "*",
|
|
28
28
|
"typescript": "*"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "894043c85eb3b67682be19a0b473e30f3550b061"
|
|
31
31
|
}
|