Npx async fetch() {
async fetch() {
const article = await fetch(
`https://dev.to/api/articles/${this.$route.params.article}`
).then((res) => res.json())
if (article.id && article.user.username === this.$route.params.username) {
this.article = article
this.$store.commit('SET_CURRENT_ARTICLE', this.article)
} else {
// set status code on server
if (process.server) {
this.$nuxt.context.res.statusCode = 404
}
// throwing an error will set $fetchState.error
throw new Error('Article not found')
}
}