Skip to content

returning a promise in the data hook raises warnings in console #187

@kfirba

Description

@kfirba

Hello.

I have a simple registration page which loads some data from the server before I show the form. When the data is being loaded I get 2 warnings in the console:

[Vue warn]: You are setting a non-existent path "ok" on a vm instance. Consider pre-initializing the property with the "data" option for more reliable reactivity and better performance.

[Vue warn]: You are setting a non-existent path "data" on a vm instance. Consider pre-initializing the property with the "data" option for more reliable reactivity and better performance.

My hook and method:

route: {
        data: function (transition) {
            return this.fetchTags()
        }
    },

    methods: {
        fetchTags: function () {
            return this.$http.get('tags', function(data, status) {
                this.tags = data.data
            }).error(function(data, status) {
                console.warn(data.error.message)
            })
        },
      // ...

Why is it returning warning in the console if I did exactly as the documentation suggests to return a promise? Did I need to do something in another way?

EDIT:

It seems like what it does is running the $set method on the Promise object that is being returned which has the ok and data keys.

How can I not run it? All I really want to do is to fetch the tags, update the this.tags array and only then show the route. How can I achieve that?

_Note: I'm using vue-resource for my http requests._

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions