Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mould-vuecli3
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
lhfe
mould-vuecli3
Commits
4be751b4
Commit
4be751b4
authored
Sep 28, 2020
by
lipengcheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: api管理中请求方法大小写bug
parent
90bcaf68
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
14 deletions
+20
-14
index.js
src/api/index.js
+20
-14
No files found.
src/api/index.js
View file @
4be751b4
...
...
@@ -19,18 +19,24 @@ const apiMap = {
login
:
{
method
:
'post'
,
url
:
'/login'
}
}
const
requestMap
=
{}
Object
.
keys
(
apiMap
).
forEach
((
alias
)
=>
{
const
{
method
,
url
,
config
}
=
apiMap
[
alias
]
requestMap
[
alias
]
=
(
dataOrParams
=
{},
instanceConf
=
{})
=>
{
// const requestMap = {}
function
injectRequest
(
apiObj
)
{
const
requestObj
=
{}
Object
.
keys
(
apiObj
).
forEach
((
alias
)
=>
{
let
{
method
,
url
,
config
}
=
apiObj
[
alias
]
method
=
method
.
toUpperCase
()
requestObj
[
alias
]
=
(
dataOrParams
=
{},
instanceConf
=
{})
=>
{
const
keyName
=
[
'PUT'
,
'POST'
,
'PATCH'
].
includes
(
method
)
?
'data'
:
'params'
return
request
({
method
:
method
.
toUpperCase
()
,
method
,
url
,
[
keyName
]:
dataOrParams
,
...
Object
.
assign
(
config
||
{},
instanceConf
)
})
}
})
})
return
requestObj
}
export
default
requestMap
export
default
injectRequest
(
apiMap
)
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