优化content-type判断

master
yutent 2023-02-17 17:08:53 +08:00
parent ea757efd31
commit 4d97503ee0
3 changed files with 3 additions and 3 deletions

View File

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

View File

@ -182,7 +182,7 @@ class _Request {
options.url += (~options.url.indexOf('?') ? '&' : '?') + '_t_=' + Date.now() options.url += (~options.url.indexOf('?') ? '&' : '?') + '_t_=' + Date.now()
} }
} else { } else {
if (!hasAttach) { if (options.body && !hasAttach) {
if (~options.headers['content-type'].indexOf('json')) { if (~options.headers['content-type'].indexOf('json')) {
params = JSON.stringify(params) params = JSON.stringify(params)
} else { } else {

View File

@ -142,7 +142,7 @@ class _Request {
} }
delete options.body delete options.body
} else { } else {
if (!hasAttach) { if (options.body && !hasAttach) {
if (~options.headers['content-type'].indexOf('json')) { if (~options.headers['content-type'].indexOf('json')) {
options.body = JSON.stringify(options.body) options.body = JSON.stringify(options.body)
} else { } else {