-
Notifications
You must be signed in to change notification settings - Fork 42
Improve accessToken logic
#228
Conversation
| "lodash.set": "^4.3.2", | ||
| "micro-api-client": "^3.3.0", | ||
| "node-fetch": "^2.2.0", | ||
| "omit.js": "^2.0.2", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was previously removed by #93
However, omit.js does not use core-js anymore, so we can use it again.
| } | ||
|
|
||
| get accessToken() { | ||
| return (get(this, 'defaultHeaders.Authorization') || '').replace('Bearer ', '') || null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.defaultHeaders is set by the constuctors, so we can assume it is defined.
| const { | ||
| defaultHeaders: { Authorization }, | ||
| } = this | ||
| if (typeof Authorization !== 'string' || !Authorization.startsWith('Bearer ')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic is slightly different, but seems to capture the actual intent. @erezrokah What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this looks much better
94ec2c3 to
62d227f
Compare
This refactors the logic related to
accessToken.