After the save_key()
function is executed, I need to invoke the get_data()
function. However, I keep encountering a
Cannot read property 'get_data' of undefined
error. My assumption is that this error occurs because the function is called from a callback. How can I resolve this issue?
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()
})
}
}