I am wondering how to switch the created
function that is already asynchronours via .then
, to async await
.
created() {
this.$http.get("wp/v2/posts").then(
response => {
for (let post in response.data) {
this.posts.push(response.data[post]);
}
this.$store.dispatch({
type: "updatePost",
value: this.posts
});
},
error => {
alert(error);
}
);
}
I could easily add async created()
and await this.$http.get
, but couldn't figure out on the error => {}
part since the curly braces for responses
will also be gone.