mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
Refactoring to use call instead of bind
This commit is contained in:
parent
2367934ab5
commit
a52895bf3f
1 changed files with 9 additions and 8 deletions
|
@ -6,13 +6,14 @@ module.exports = (client) => {
|
|||
if (req.headers.authorization) {
|
||||
_.set(params, 'headers.authorization', req.headers.authorization);
|
||||
}
|
||||
const api = _.get(client, endpoint).bind(client);
|
||||
return api(params).catch((err) => {
|
||||
if (err.status === 401) {
|
||||
const options = { realm: 'Authorization Required' };
|
||||
return Promise.reject(Boom.unauthorized(err.body, 'Basic', options));
|
||||
}
|
||||
return Promise.reject(err);
|
||||
});
|
||||
return _.get(client, endpoint)
|
||||
.call(client, params)
|
||||
.catch((err) => {
|
||||
if (err.status === 401) {
|
||||
const options = { realm: 'Authorization Required' };
|
||||
return Promise.reject(Boom.unauthorized(err.body, 'Basic', options));
|
||||
}
|
||||
return Promise.reject(err);
|
||||
});
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue