Code:
export default {
data() {
return {
nameCity: '',
}
},
methods: {
findCity(event){
event.preventDefault()
findCityCust().then(function(response) {
console.log(response)
this.nameCity = response;
})
},
},
}
And here - this.nameCity = response; - throws an error Uncaught (in promise) TypeError: Cannot read properties of undefined
How to work with fields from asynchronous methods in Vue 3?