axios init
This commit is contained in:
parent
3e00b4dda4
commit
3bd0724168
@ -30,9 +30,12 @@ export default {
|
|||||||
handlePhotoChange (value) {
|
handlePhotoChange (value) {
|
||||||
this.image = value
|
this.image = value
|
||||||
},
|
},
|
||||||
checkPhoto (photo) {
|
async checkPhoto (photo) {
|
||||||
// let formData = new FormData();
|
const formData = new FormData()
|
||||||
// formData.append('')
|
formData.append('file', photo.file)
|
||||||
|
|
||||||
|
const res = await this.$store.dispatch('axios/file', ['/image/check', formData])
|
||||||
|
return res
|
||||||
},
|
},
|
||||||
clear () {
|
clear () {
|
||||||
this.image = null
|
this.image = null
|
||||||
|
@ -37,11 +37,7 @@ export const actions = {
|
|||||||
file: ({ commit, rootState, state, dispatch }, params) => {
|
file: ({ commit, rootState, state, dispatch }, params) => {
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
return new Promise(async (resolve, reject) => {
|
return new Promise(async (resolve, reject) => {
|
||||||
const headers = {
|
const request = await axios.post(`${state.url}${params[0]}`, params[1]).catch((error) => {
|
||||||
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) => {
|
|
||||||
dispatch('error', error.response)
|
dispatch('error', error.response)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user