Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
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
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
4128c738
Commit
4128c738
authored
Aug 10, 2018
by
Robert Knight
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use ES6 destructuring to tidy up a Promise `then` callback
parent
be56b227
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
6 deletions
+4
-6
api.js
src/sidebar/services/api.js
+4
-6
No files found.
src/sidebar/services/api.js
View file @
4128c738
...
...
@@ -137,15 +137,13 @@ function createAPICall($http, $q, links, route, tokenGetter) {
// `$q.all` is used here rather than `Promise.all` because testing code that
// mixes native Promises with the `$q` promises returned by `$http`
// functions gets awkward in tests.
var
token
;
return
$q
.
all
([
links
,
tokenGetter
()]).
then
(
function
(
linksAndToken
)
{
var
links
=
linksAndToken
[
0
];
token
=
linksAndToken
[
1
];
var
accessToken
;
return
$q
.
all
([
links
,
tokenGetter
()]).
then
(([
links
,
token
])
=>
{
var
descriptor
=
get
(
links
,
route
);
var
url
=
urlUtil
.
replaceURLParams
(
descriptor
.
url
,
params
);
var
headers
=
{};
accessToken
=
token
;
if
(
token
)
{
headers
.
Authorization
=
'Bearer '
+
token
;
}
...
...
@@ -161,7 +159,7 @@ function createAPICall($http, $q, links, route, tokenGetter) {
return
$http
(
req
);
}).
then
(
function
(
response
)
{
if
(
options
.
includeMetadata
)
{
return
{
data
:
response
.
data
,
token
};
return
{
data
:
response
.
data
,
token
:
accessToken
};
}
else
{
return
response
.
data
;
}
...
...
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