feat: post方法新增扩展参数

This commit is contained in:
jackhoo_98 2023-03-03 11:35:22 +08:00
parent c3da2ad806
commit dd1c05e0b8
1 changed files with 8 additions and 3 deletions

View File

@ -24,12 +24,17 @@ export const request = axios.create({
* @param {String} url
* @param {Object} [data]
* @param {String} responseType responseType = 'blob'
* @param {Object|String} [ext] headersext对象内包含headers对象
* {
headers: {'Content-Type': 'text/plain;charset=UTF-8'},
}
* @returns {AxiosInstance}
*/
export const post = function<T>(url: string, data = {}, params = {}) {
params = typeof params === 'string' ? { responseType: params } : params
export const post = function<T>(url: string, data = {}, params = {}, ext={}) {
ext = typeof ext === 'string' ? { responseType: ext } : ext
return request<any, AxiosResponseRewrite<T>>({
...params,
...ext,
params,
method: 'POST',
url,
data