fcc-core
Version:
Fusion communication center.
27 lines (26 loc) • 803 B
JavaScript
import httpRequst from './instance'
import { formateData, jsonResultCallback } from './formate'
import BaseException from '../../errors/base-exception'
export default async (options, xw) => {
let data = formateData(options, xw)
return httpRequst({
url: data.url,
method: 'post',
data: data['data'],
headers: {
'Content-Type': data['contentType']
}
}).then(res => {
let result = jsonResultCallback(res.data, xw)
if (+result.code === 10069) { // 重写会话过期逻辑
throw new BaseException(410)
} else {
if (+result.code !== 0) { // 后台报错后在前端抛出
throw new BaseException(551, result.msg)
}
return Promise.resolve(result)
}
}).catch(e => {
return Promise.reject(e)
})
}