I am trying to get the data I got from a method-and send it to the vue-model where it is defined. I have no idea what I am doing wrong because, it works if the data is already there, but trying to push it back--using vm...does not work. I want to get the data from myenrollemnts put in the the model and use it as a variable so that I can place in the hyperlink as a variable..any help
new Vue({
el: "#app",
data: {
myEnrollments:'',
myScore:''
},
mounted:function(){
this.getMyEnrollments();
this.getMyUrl();
},
methods: {
getMyEnrollments:function(){
var vm = this;
$.ajax({
url: "https://www.example.com/users/myinfo",
type: 'Get',
headers: {
accept: "application/json;odata=verbose"
},
success: function(data) {
console.log(data);
vm.FirstName = data.FirstName;
vm.ProfileIdentifier=data.ProfileIdentifier;
vm.Identifier=data.Identifier;
vm.myEnrollments=data.myEnrollments;
}
})
},
getMyUrl:function(){
var vm = this;
$.ajax({
url: "https://www.example.com/users/myURL/"+this.$root.$data.myEnrollments+"/orgUnits",
type: 'Get',
headers: {
accept: "application/json;odata=verbose"
},
success: function(data) {
console.log(data);
}
})
}
}
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="app">
<h2>Todos:</h2>
</div>