Wednesday, 3 March 2021

Why my first load data axios is return 404 Vue Js?

so guys I've tried to fetch data and show it inside my component. But the problem is, fetching data got 404 or data not show for the first load.. but when I try to reload again data is shown as should be. And one thing.. the data was success upload to the server even the response status 404 as I said

By the way guys this is my reviewClient.js

getDraft() {
  return api.get("/reviews/draft")
}

this is my Store

async fetchDraft({ commit }) {
  try {
    let {
      data: { data }
    } = await reviewClient.getDraft()
    commit("SET_DRAFT", data)
  } catch (error) {
    return Promise.reject(error)
  }
}

and this is how I call fetchDraft from a store inside my component

async created() {
  await this.getDraft()
}

methods: {
  async getDraft() {
    try {
      await this.$store.dispatch("review/fetchDraft")
      this.scrollToTop()
    } catch (error) {
      error
    }
  }
}

this is a sample of my problem above

https://ibb.co/k6xyRc3



from Why my first load data axios is return 404 Vue Js?

No comments:

Post a Comment