Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No errors returned, when request failed by timeout #2

Closed
vik-buchinski-azati opened this issue Jun 21, 2017 · 3 comments
Closed

No errors returned, when request failed by timeout #2

vik-buchinski-azati opened this issue Jun 21, 2017 · 3 comments

Comments

@vik-buchinski-azati
Copy link

No description provided.

@rogerjin12
Copy link
Contributor

Per #1 , can you give that a try let me know if that resolves this issue?

@vik-buchinski-azati
Copy link
Author

vik-buchinski-azati commented Jun 22, 2017

@rogerjin12 I tested, and I see, that this case still doesn't work.
my code:

this.butter.post.list({ page: pageNumber, page_size: pageSize }).then(
      (response) => {
        clearTimeout(this.butterErrorTimeout); // timeout bugfix
        let newState = {};

        if (response.status === 200) {
          newState = {
            posts: response.data.data,
            pagination: response.data.meta,
            currentPage: pageNumber,
          };
        }

        newState = {
          ...newState,
          loading: false,
        };

        this.setState(newState);
      }
    );

So, how i see, that it should work:

  1. Fetch posts
  2. Request cancelled by timeout
  3. .then callback called with appropriate status and statusMessage (but on this step nothing called or returned)

@ButterCMS ButterCMS deleted a comment from rogerjin12 Jun 27, 2017
@rogerjin12
Copy link
Contributor

rogerjin12 commented Jun 27, 2017

@vik-buchinski-azati Hi Victor. I investigated this and an error is returned. You need to catch it as part of the promise callback chain. Try this:

var butter = require('buttercms')('your api token', true, 1);

butter.post.list({page: 1, page_size: 10})
  .then(function(response) {
    console.log(response.data)
  }).catch(function(response) {
    console.log('this is an error', response)
  });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants