fixed undefined

master
yutent 2024-10-28 17:16:12 +08:00
parent 5b403fb269
commit 763792d7f1
2 changed files with 14 additions and 5 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@bytedo/fetch",
"version": "2.1.7",
"version": "2.1.8",
"description": "全新的ajax封装。分2个版本, 一个基于XMLHttpRequest, 一个基于window.fetch",
"main": "dist/next.js",
"files": [

View File

@ -84,13 +84,17 @@ export const Format = {
mkFormData(data) {
let form = new FormData()
for (let i in data) {
let el = data[i]
if (Array.isArray(el)) {
el.forEach(function (it) {
let val = data[i]
if (val === void 0) {
val = ''
}
if (Array.isArray(val)) {
val.forEach(function (it) {
form.append(i + '[]', it)
})
} else {
form.append(i, data[i])
form.append(i, val)
}
}
return form
@ -105,6 +109,11 @@ export const Format = {
if (/native code/.test(v)) {
return
}
if (v === void 0) {
v = ''
}
let _type = getType(v)
v = typeof v === 'function' ? v() : v