Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
broadcast_cloud
/
web-live
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
2
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
875e989e
authored
Apr 14, 2021
by
MichaelJier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test
parent
0a3cfb51
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
6 deletions
+13
-6
plugins/API/request.js
+13
-6
No files found.
plugins/API/request.js
View file @
875e989e
...
...
@@ -9,7 +9,7 @@
import
qs
from
'qs'
;
import
axios
from
'axios'
;
import
Layer
from
'@/plugins/Layer/index'
;
import
md5
from
'js-md5'
;
// import md5 from 'js-md5';
// import LRU from 'lru-cache'
const
Cookie
=
process
.
client
?
require
(
'js-cookie'
)
:
{};
const
Sentry
=
process
.
client
?
require
(
'@sentry/browser'
)
:
require
(
'@sentry/node'
);
...
...
@@ -41,6 +41,10 @@ service.interceptors.request.use(
config
.
headers
[
'token'
]
=
Cookie
.
get
(
'token'
)
||
Cookie
.
get
(
'BCC_PROGRAM_USER_LOGIN_TOKEN'
)
||
''
;
}
else
{
const
{
params
=
{},
headers
=
{}
}
=
config
Sentry
.
captureException
(
new
Error
(
`
${
config
.
url
}
;
${
JSON
.
stringify
(
params
)}
;
${
JSON
.
stringify
(
headers
)}
`
)
)
// 服务端api缓存
// const { params = {}, headers = {} } = config
// const key = md5(config.url + JSON.stringify(params) + JSON.stringify(headers))
...
...
@@ -66,11 +70,14 @@ service.interceptors.response.use(
const
{
status
,
data
,
config
}
=
res
;
if
(
status
===
200
)
{
const
{
code
,
errorCode
,
errorMessage
}
=
data
;
// if (!process.client) {
// const { params = {}, headers = {} } = config
// const key = md5(config.url + JSON.stringify(params) + JSON.stringify(headers))
// CACHED.set(key, data)
// }
if
(
!
process
.
client
)
{
// const { params = {}, headers = {} } = config
// const key = md5(config.url + JSON.stringify(params) + JSON.stringify(headers))
// CACHED.set(key, data)
Sentry
.
captureException
(
new
Error
(
`
${
status
}
;
${
JSON
.
stringify
(
data
)}
;
${
JSON
.
stringify
(
config
)}
`
)
);
}
if
((
code
!==
200
||
errorCode
!==
0
)
&&
code
!==
0
)
{
Sentry
.
captureException
(
new
Error
(
`
${
status
}
;
${
JSON
.
stringify
(
data
)}
;
${
JSON
.
stringify
(
config
)}
`
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment