How use promise in new interceptors format (version 1.4.0)?
See original GitHub issueHow change this code in new format?
/**
* @param request
* @param next
*/
export default (request, next) => {
loadToken()
.then((token) => {
// continue to next interceptor
request.headers.set('Authorization', token.token_type + ' ' + token.access_token);
next();
})
.catch(error => {
return next(request.respondWith({
message: 'Access token not fetch',
}, {
status: 401,
statusText: 'Unauthorized'
}))
})
;
};
Issue Analytics
- State:
- Created 6 years ago
- Reactions:6
- Comments:6
Top Results From Across the Web
promise-interceptor - npm
An interceptor tool for Promise.. Latest version: 0.2.0, last published: 5 years ago. Start using promise-interceptor in your project by ...
Read more >$q - AngularJS: API
This method returns a new promise which is resolved or rejected via the return value of the successCallback , errorCallback (unless that value...
Read more >Npo-api-interceptor - npm.io
Run nvm to switch to the right Node.js version: nvm use . Install the dependencies: yarn install . To publish a new version:...
Read more >Promise - JavaScript - MDN Web Docs
All these methods take an iterable of promises (thenables, to be exact) and return a new promise. They all support subclassing, ...
Read more >axios | Yarn - Package Manager
Promise based HTTP client for the browser and node.js. Website • Documentation · npm version CDNJS Build status Gitpod Ready-to-Code code coverage install ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ve finally given up and started using vue-axios. It behaves the way you’d expect and is pretty much a drop-in replacement.
This project has poor documentation and with things like this is unusable in real/production scenarios.
I’m using version 1.5.1