Skip to content

Commit

Permalink
feat: 返回数据增加rawData,保留返回的原始数据
Browse files Browse the repository at this point in the history
  • Loading branch information
lei-mu committed Aug 23, 2022
1 parent d62240c commit 3924b7c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/lib/adapters/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import buildURL from '../helpers/buildURL'
import buildFullPath from '../core/buildFullPath'
import settle from '../core/settle'
import { isUndefined } from "../utils"
import {isUndefined} from "../utils"

/**
* 返回可选值存在的配置
Expand All @@ -20,13 +20,14 @@ const mergeKeys = (keys, config2) => {
}
export default (config) => {
return new Promise((resolve, reject) => {
let fullPath = buildURL(buildFullPath(config.baseURL, config.url), config.params,config.paramsSerializer)
let fullPath = buildURL(buildFullPath(config.baseURL, config.url), config.params, config.paramsSerializer)
const _config = {
url: fullPath,
header: config.header,
complete: (response) => {
config.fullPath = fullPath
response.config = config
response.rawData = response.data
try {
// 对可能字符串不是json 的情况容错
if (typeof response.data === 'string') {
Expand Down Expand Up @@ -90,7 +91,7 @@ export default (config) => {
'firstIpv4',
// #endif
]
requestTask = uni.request({..._config,...mergeKeys(optionalKeys, config)})
requestTask = uni.request({..._config, ...mergeKeys(optionalKeys, config)})
}
if (config.getTask) {
config.getTask(requestTask, config)
Expand Down

0 comments on commit 3924b7c

Please sign in to comment.