tenjin-ui-kit 0.2.50 → 0.2.51
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/common/hooks/newApiHook.js +34 -22
- package/package.json +1 -1
|
@@ -98,12 +98,14 @@ var useAPI = function useAPI() {
|
|
|
98
98
|
setLoading = _useState30[1];
|
|
99
99
|
var useGet = /*#__PURE__*/function () {
|
|
100
100
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(url, action) {
|
|
101
|
-
var response;
|
|
101
|
+
var response, parsedError;
|
|
102
102
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
103
103
|
while (1) switch (_context.prev = _context.next) {
|
|
104
104
|
case 0:
|
|
105
105
|
_context.prev = 0;
|
|
106
|
-
setLoading(
|
|
106
|
+
setLoading({
|
|
107
|
+
getLoading: true
|
|
108
|
+
});
|
|
107
109
|
_context.next = 4;
|
|
108
110
|
return (0, _http.getSecureClient)().get(url);
|
|
109
111
|
case 4:
|
|
@@ -114,18 +116,19 @@ var useAPI = function useAPI() {
|
|
|
114
116
|
setLoading({
|
|
115
117
|
getLoading: false
|
|
116
118
|
});
|
|
117
|
-
_context.next =
|
|
119
|
+
_context.next = 14;
|
|
118
120
|
break;
|
|
119
121
|
case 9:
|
|
120
122
|
_context.prev = 9;
|
|
121
123
|
_context.t0 = _context["catch"](0);
|
|
124
|
+
parsedError = (0, _http.parseAxiosError)(_context.t0);
|
|
122
125
|
setErrorMessage({
|
|
123
|
-
getError:
|
|
126
|
+
getError: parsedError.message
|
|
124
127
|
});
|
|
125
128
|
setLoading({
|
|
126
129
|
getLoading: false
|
|
127
130
|
});
|
|
128
|
-
case
|
|
131
|
+
case 14:
|
|
129
132
|
case "end":
|
|
130
133
|
return _context.stop();
|
|
131
134
|
}
|
|
@@ -137,12 +140,14 @@ var useAPI = function useAPI() {
|
|
|
137
140
|
}();
|
|
138
141
|
var usePost = /*#__PURE__*/function () {
|
|
139
142
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(url, body, action) {
|
|
140
|
-
var response;
|
|
143
|
+
var response, parsedError;
|
|
141
144
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
142
145
|
while (1) switch (_context2.prev = _context2.next) {
|
|
143
146
|
case 0:
|
|
144
147
|
_context2.prev = 0;
|
|
145
|
-
setLoading(
|
|
148
|
+
setLoading({
|
|
149
|
+
postLoading: true
|
|
150
|
+
});
|
|
146
151
|
_context2.next = 4;
|
|
147
152
|
return (0, _http.getSecureClient)().post(url, body);
|
|
148
153
|
case 4:
|
|
@@ -153,18 +158,19 @@ var useAPI = function useAPI() {
|
|
|
153
158
|
setLoading({
|
|
154
159
|
postLoading: false
|
|
155
160
|
});
|
|
156
|
-
_context2.next =
|
|
161
|
+
_context2.next = 14;
|
|
157
162
|
break;
|
|
158
163
|
case 9:
|
|
159
164
|
_context2.prev = 9;
|
|
160
165
|
_context2.t0 = _context2["catch"](0);
|
|
166
|
+
parsedError = (0, _http.parseAxiosError)(_context2.t0);
|
|
161
167
|
setErrorMessage({
|
|
162
|
-
postError:
|
|
168
|
+
postError: parsedError.message
|
|
163
169
|
});
|
|
164
170
|
setLoading({
|
|
165
171
|
postLoading: false
|
|
166
172
|
});
|
|
167
|
-
case
|
|
173
|
+
case 14:
|
|
168
174
|
case "end":
|
|
169
175
|
return _context2.stop();
|
|
170
176
|
}
|
|
@@ -176,34 +182,37 @@ var useAPI = function useAPI() {
|
|
|
176
182
|
}();
|
|
177
183
|
var usePut = /*#__PURE__*/function () {
|
|
178
184
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(url, body, action) {
|
|
179
|
-
var response;
|
|
185
|
+
var response, _response, parsedError;
|
|
180
186
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
181
187
|
while (1) switch (_context3.prev = _context3.next) {
|
|
182
188
|
case 0:
|
|
183
189
|
_context3.prev = 0;
|
|
184
|
-
setLoading(
|
|
190
|
+
setLoading({
|
|
191
|
+
putLoading: true
|
|
192
|
+
});
|
|
185
193
|
_context3.next = 4;
|
|
186
194
|
return (0, _http.getSecureClient)().put(url, body);
|
|
187
195
|
case 4:
|
|
188
|
-
|
|
196
|
+
_response = _context3.sent;
|
|
189
197
|
setResult({
|
|
190
|
-
putResult:
|
|
198
|
+
putResult: _response
|
|
191
199
|
});
|
|
192
200
|
setLoading({
|
|
193
201
|
putLoading: false
|
|
194
202
|
});
|
|
195
|
-
_context3.next =
|
|
203
|
+
_context3.next = 14;
|
|
196
204
|
break;
|
|
197
205
|
case 9:
|
|
198
206
|
_context3.prev = 9;
|
|
199
207
|
_context3.t0 = _context3["catch"](0);
|
|
208
|
+
parsedError = (0, _http.parseAxiosError)(_context3.t0);
|
|
200
209
|
setErrorMessage({
|
|
201
|
-
putError:
|
|
210
|
+
putError: parsedError.message
|
|
202
211
|
});
|
|
203
212
|
setLoading({
|
|
204
213
|
putLoading: false
|
|
205
214
|
});
|
|
206
|
-
case
|
|
215
|
+
case 14:
|
|
207
216
|
case "end":
|
|
208
217
|
return _context3.stop();
|
|
209
218
|
}
|
|
@@ -215,12 +224,14 @@ var useAPI = function useAPI() {
|
|
|
215
224
|
}();
|
|
216
225
|
var useDelete = /*#__PURE__*/function () {
|
|
217
226
|
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(url, action) {
|
|
218
|
-
var response;
|
|
227
|
+
var response, parsedError;
|
|
219
228
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
220
229
|
while (1) switch (_context4.prev = _context4.next) {
|
|
221
230
|
case 0:
|
|
222
231
|
_context4.prev = 0;
|
|
223
|
-
setLoading(
|
|
232
|
+
setLoading({
|
|
233
|
+
deleteLoading: true
|
|
234
|
+
});
|
|
224
235
|
_context4.next = 4;
|
|
225
236
|
return (0, _http.getSecureClient)().delete(url);
|
|
226
237
|
case 4:
|
|
@@ -231,18 +242,19 @@ var useAPI = function useAPI() {
|
|
|
231
242
|
setLoading({
|
|
232
243
|
deleteLoading: false
|
|
233
244
|
});
|
|
234
|
-
_context4.next =
|
|
245
|
+
_context4.next = 14;
|
|
235
246
|
break;
|
|
236
247
|
case 9:
|
|
237
248
|
_context4.prev = 9;
|
|
238
249
|
_context4.t0 = _context4["catch"](0);
|
|
250
|
+
parsedError = (0, _http.parseAxiosError)(_context4.t0);
|
|
239
251
|
setErrorMessage({
|
|
240
|
-
deleteError:
|
|
252
|
+
deleteError: parsedError.message
|
|
241
253
|
});
|
|
242
254
|
setLoading({
|
|
243
255
|
deleteLoading: false
|
|
244
256
|
});
|
|
245
|
-
case
|
|
257
|
+
case 14:
|
|
246
258
|
case "end":
|
|
247
259
|
return _context4.stop();
|
|
248
260
|
}
|