Toggle navigation
Toggle navigation
This project
Loading...
Sign in
罗广聪
/
ProtectGod
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
罗广聪
2017-09-28 09:34:45 +0800
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
0c405c212fb9aa72ce8a7e66a9db403c73abe63d
0c405c21
2 parents
3dc525a1
3f61c1a4
Merge branch 'dev' of gitlab.brae.co:amanda/ProtectGod into dev
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
6 deletions
src/utils/fetch.js
src/utils/fetch.js
View file @
0c405c2
...
...
@@ -12,14 +12,14 @@ const MAIN_URL = 'https://devpay.brae.co';
* @param {function} errCB 失败回调函数
* @param {Object} header 补充包头
*/
export
default
function
post
(
url
,
data
,
sucCB
,
errCB
,
header
=
{})
{
export
default
function
(
url
,
data
,
sucCB
,
errCB
,
header
=
{})
{
const
requestUrl
=
`
${
MAIN_URL
}${
url
}
`
;
const
body
=
JSON
.
stringify
(
data
);
const
headers
=
{
"Accept"
:
"application/json"
,
"Content-Type"
:
"application/json"
,
'Accept'
:
'application/json'
,
'Content-Type'
:
'application/json'
,
...
header
,
}
}
;
fetch
(
requestUrl
,
{
method
:
'POST'
,
body
:
body
,
...
...
@@ -37,12 +37,12 @@ export default function post(url, data, sucCB, errCB, header = {}) {
errCB
(
res
);
}
}).
catch
(
err
=>
{
console
.
log
(
err
)
console
.
log
(
err
)
;
// 所有非 200 的情况都作为服务器内部错误处理
if
(
err
.
message
===
'server'
)
{
errCB
({
code
:
500
,
enmsg
:
'server error'
,
cnmsg
:
'服务器内部错误'
,
data
:
null
});
}
else
{
errCB
({
code
:
500
,
enmsg
:
'client error'
,
cnmsg
:
'网络异常'
,
data
:
null
});
}
})
})
;
}
\ No newline at end of file
...
...
Please
register
or
login
to post a comment