I am using surveyjs in vue, and I am trying to get my var json
questions from my API.
Using vue-resource, I make a GET request to the API, and save the response in questions
and put it on var json
export default {
components: {
Survey
},
data(){
this.$http.get('api')
.then(res => res.json())
.then(questions => {
this.questions = questions;
});
var json = this.questions;
var model = new SurveyVue.Model(json);
return {
survey: model,
questions:''
}
}
}
Using console.log(json)
, I get undefined
. So, what´s the correct way to access API response in this case?