npx async fetch 28 29 7b

Solutions on MaxInterview for npx async fetch 28 29 7b by the best coders in the world

showing results for - "npx async fetch 28 29 7b"
Yohann
17 Mar 2020
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