axios init
This commit is contained in:
parent
3e00b4dda4
commit
3bd0724168
@ -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
|
||||
|
@ -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)
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user