Skip to content

Commit

Permalink
feat: create method for calling the API with credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
AlejandroAkbal committed Mar 18, 2022
1 parent a853a5c commit 704c174
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,19 @@ export const actions = {
})
}

const response = await this.$axios.$get(url, {
const response = await this.$axios.get(url, options)

return response
},

async simpleApiFetch({ state, dispatch }, { url, options }) {
const AXIOS_OPTIONS = {
headers: {
'Authorization': this.$auth.strategy.token.get()
},
...options
})
}
}

return response
return await dispatch('simpleFetch', { url, options: { ...options, ...AXIOS_OPTIONS } })
},

errorManager({ commit, dispatch }, { operation, value, message }) {
Expand Down

0 comments on commit 704c174

Please sign in to comment.