1async fetch() {
2 const article = await fetch(
3 `https://dev.to/api/articles/${this.$route.params.article}`
4 ).then((res) => res.json())
5
6 if (article.id && article.user.username === this.$route.params.username) {
7 this.article = article
8 this.$store.commit('SET_CURRENT_ARTICLE', this.article)
9 } else {
10 // set status code on server
11 if (process.server) {
12 this.$nuxt.context.res.statusCode = 404
13 }
14 // throwing an error will set $fetchState.error
15 throw new Error('Article not found')
16 }
17}
18