|
@@ -45,22 +45,27 @@ function requestInterceptor(url, options) {
|
45
|
45
|
}
|
46
|
46
|
|
47
|
47
|
async function responseInterceptor(response, ctx) {
|
48
|
|
- const contextType = response.headers.get('content-type');
|
49
|
|
- if (contextType.indexOf('json') > -1) {
|
50
|
|
- const result = await response.clone().json();
|
51
|
|
- if (result?.token || result?.data?.token) {
|
52
|
|
- localStorage.setItem('token', result?.token || result?.data?.token);
|
53
|
|
- }
|
54
|
|
- }
|
55
|
48
|
|
56
|
|
- if (contextType.indexOf('application/vnd.ms-excel') > -1) {
|
57
|
|
- const data = await response.clone().blob();
|
58
|
|
- console.info(response);
|
59
|
|
- const content = response.headers.get('content-disposition');
|
60
|
|
- const fileName = content.replace('attachment;filename=', '');
|
61
|
|
- downloadBlob(data, decodeURIComponent(fileName));
|
|
49
|
+ try {
|
|
50
|
+ const contextType = response.headers.get('content-type');
|
|
51
|
+ if (contextType.indexOf('json') > -1) {
|
|
52
|
+ const result = await response.clone().json();
|
|
53
|
+ if (result?.token || result?.data?.token) {
|
|
54
|
+ localStorage.setItem('token', result?.token || result?.data?.token);
|
|
55
|
+ }
|
|
56
|
+ }
|
|
57
|
+
|
|
58
|
+ if (contextType.indexOf('application/vnd.ms-excel') > -1) {
|
|
59
|
+ const data = await response.clone().blob();
|
|
60
|
+ console.info(response);
|
|
61
|
+ const content = response.headers.get('content-disposition');
|
|
62
|
+ const fileName = content.replace('attachment;filename=', '');
|
|
63
|
+ downloadBlob(data, decodeURIComponent(fileName));
|
|
64
|
+ }
|
|
65
|
+ } catch (e) {
|
|
66
|
+ console.error(e);
|
62
|
67
|
}
|
63
|
|
-
|
|
68
|
+
|
64
|
69
|
return response;
|
65
|
70
|
}
|
66
|
71
|
|