axios init

This commit is contained in:
Novembert 2022-01-03 21:02:57 +01:00
parent 3e00b4dda4
commit 3bd0724168
2 changed files with 7 additions and 8 deletions

View File

@ -30,9 +30,12 @@ export default {
handlePhotoChange (value) {
this.image = value
},
checkPhoto (photo) {
// let formData = new FormData();
// formData.append('')
async checkPhoto (photo) {
const formData = new FormData()
formData.append('file', photo.file)
const res = await this.$store.dispatch('axios/file', ['/image/check', formData])
return res
},
clear () {
this.image = null

View File

@ -37,11 +37,7 @@ export const actions = {
file: ({ commit, rootState, state, dispatch }, params) => {
// eslint-disable-next-line
return new Promise(async (resolve, reject) => {
const headers = {
headers: params[2] && params[2].guest ? { url: `${params[0]}` } : { Authorization: `Bearer ${rootState.auth.token}`, url: `${params[0]}` }
}
const request = await axios.post(`${state.url}/api/store${params[0]}`, params[1], headers).catch((error) => {
const request = await axios.post(`${state.url}${params[0]}`, params[1]).catch((error) => {
dispatch('error', error.response)
})