question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How use promise in new interceptors format (version 1.4.0)?

See original GitHub issue

How 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:open
  • Created 6 years ago
  • Reactions:6
  • Comments:6

github_iconTop GitHub Comments

4reactions
stgogmcommented, Mar 27, 2018

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.

0reactions
star1105commented, Sep 15, 2018

I’m using version 1.5.1

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found