I have the function below from: https://github.com/anaida07/MEVN-boilerplate/blob/master/client/src/components/EditPost.vue
methods: {
async getPost () {
const response = await PostsService.getPost({
id: this.$route.params.id
})
this.title = response.data.title
this.description = response.data.description
// this.$router.push({ name: 'Posts' })
},
I am learning about MEVN. I wanted to know if there was anyway to write the same function without using async/await. I currently have come up with the following:
methods: {
getPost () {
const response = PostsService
.getPost({
id: this.$route.params.id
})
this.title = response.data.title
this.description = response.data.description
//this.$router.push({ name: 'Posts' })
},
But I am getting an error in my console log saying: Error in mounted hook: "TypeError: response.data is undefined". Any help would be greatly appreciated.
async-awaitsyntax?