Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
U
uview-ui
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李晖
uview-ui
Commits
06b436b5
Commit
06b436b5
authored
Jun 04, 2020
by
费陶勇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 修复http模块在处理拦截器时返回Promise实例对象导致处理错误的问题
http模块修复处理不支持Promise实例对象返回的Resolved或Rejected的值
parent
3dcec9f3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
index.js
uview-ui/libs/request/index.js
+4
-4
No files found.
uview-ui/libs/request/index.js
View file @
06b436b5
...
...
@@ -14,7 +14,7 @@ class Request {
// 检查请求拦截
if
(
this
.
interceptor
.
request
&&
typeof
this
.
interceptor
.
request
===
'
function
'
)
{
let
tmpConfig
=
{};
let
interceptorReuest
=
this
.
interceptor
.
request
(
options
);
let
interceptorReuest
=
await
this
.
interceptor
.
request
(
options
);
if
(
interceptorReuest
===
false
)
{
return
false
;
}
...
...
@@ -29,7 +29,7 @@ class Request {
options
.
method
=
options
.
method
||
this
.
config
.
method
;
return
new
Promise
((
resolve
,
reject
)
=>
{
options
.
complete
=
(
response
)
=>
{
options
.
complete
=
async
(
response
)
=>
{
// 请求返回后,隐藏loading(如果请求返回快的话,可能会没有loading)
uni
.
hideLoading
();
// 清除定时器,如果请求回来了,就无需loading
...
...
@@ -38,7 +38,7 @@ class Request {
if
(
this
.
config
.
originalData
)
{
// 判断是否存在拦截器
if
(
this
.
interceptor
.
response
&&
typeof
this
.
interceptor
.
response
===
'
function
'
)
{
let
resInterceptors
=
this
.
interceptor
.
response
(
response
);
let
resInterceptors
=
await
this
.
interceptor
.
response
(
response
);
// 如果拦截器不返回false,就将拦截器返回的内容给this.$u.post的then回调
if
(
resInterceptors
!==
false
)
{
resolve
(
resInterceptors
);
...
...
@@ -53,7 +53,7 @@ class Request {
}
else
{
if
(
response
.
statusCode
==
200
)
{
if
(
this
.
interceptor
.
response
&&
typeof
this
.
interceptor
.
response
===
'
function
'
)
{
let
resInterceptors
=
this
.
interceptor
.
response
(
response
.
data
);
let
resInterceptors
=
await
this
.
interceptor
.
response
(
response
.
data
);
if
(
resInterceptors
!==
false
)
{
resolve
(
resInterceptors
);
}
else
{
...
...
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