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

Accessing data from error callback #20

Closed
jleskovar opened this issue Jan 2, 2017 · 2 comments
Closed

Accessing data from error callback #20

jleskovar opened this issue Jan 2, 2017 · 2 comments
Assignees
Labels

Comments

@jleskovar
Copy link

jleskovar commented Jan 2, 2017

Vue, vue-apollo, apollo-client et al are new technologies for me, so excuse the newbie question :-)

I'm trying to implement a simple error callback for my vue component (vue-loader) to set a variable in my data context, as follows:

  apollo: {
    requestMappings: {
      query: requestMappings,
      update(data) {
        return data.spring.requestMappings;
      },
      error: (err) => {
        console.log(this)
        showNetworkError = true
      }
    }
  }

Here, showNetworkError is not accessible, as the "this" object is the apollo query object. I've tried different styles of "error: function(err) { .. } and "error(err) { ... }", with not much luck. Clearly I feel like I've missed something obvious - how are we able to set data from the callbacks?

Kind regards
James

@Akryum
Copy link
Member

Akryum commented Jan 2, 2017

Try the 1.2.3 version of vue-apollo.

@Akryum Akryum self-assigned this Jan 2, 2017
@Akryum Akryum added the bug label Jan 2, 2017
@Akryum Akryum closed this as completed in 905ff10 Jan 2, 2017
@jleskovar
Copy link
Author

Looks like it's fixed now 👍

Can now access data via this.$data...

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

No branches or pull requests

2 participants