varun-2301
372
3
Vue

Assign dynamic value to variable

Posted 11 months ago by varun-2301

Hello,

I am new to vue and wishing to set a variable with dynamic data which I am getting from api but could not able to set. Below is the html snippet :-

Users

For displaying value, I have tried different m>thods like using v-text="resultSet.userCount" or displaying like this {{resultSet.userCount}} but was unable to?

Here is my script :-

export default { mounted() { var app = this; axios.get(this.globalUrl+'api/v1/dashboard') .then(function (resp) { alert('success'); app.resultSet = resp.data;
            })
            .catch(function (error) {
                console.log(error);
                alert("Could not load data");
            });
    },
    data: function () {
        return {
            resultSet:{
                userCount: 0
            }
        }
    }
}

</script

Any help please

Please sign in or create an account to participate in this conversation.