I need to call the function get_data()
once the function save_key()
is done executing, the problem is that i get a Cannot read property 'get_data' of undefined
error. I assume i'm getting it because the function is called from a callback. How can i solve this?
methods: {
async get_data(){
var response = await axios.get("http://127.0.0.1:8000/retrieve_user_data");
this.keys = response['data']
},
save_key(){
var key_data = {'action': 'save', 'key': this.form.key}
return axios({
method: 'post',
url: 'http://127.0.0.1:8000/save_data/',
data: key_data,
withCredentials: true,
headers: {}
}).then(function (response) {
this.get_data()
})
}
}