master
宇天 2020-08-31 17:49:45 +08:00
parent ae80130dea
commit 0e5c353fbb
3 changed files with 21 additions and 7 deletions

View File

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

View File

@ -77,11 +77,18 @@ class _Request {
control.abort() control.abort()
} }
if (__INIT__.headers && options.headers) { var headers = this.options.headers
Object.assign(__INIT__.headers, options.headers)
if (__INIT__.headers) {
Object.assign(headers, __INIT__.headers)
} }
Object.assign(this.options, __INIT__, options, { url }) if (options.headers) {
Object.assign(headers, options.headers)
delete options.headers
}
Object.assign(this.options, __INIT__, options, { url, headers })
this.__next__() this.__next__()
return this.defer.promise return this.defer.promise

View File

@ -50,11 +50,18 @@ class _Request {
options.signal = this.control.signal options.signal = this.control.signal
} }
if (__INIT__.headers && options.headers) { var headers = this.options.headers
Object.assign(__INIT__.headers, options.headers)
if (__INIT__.headers) {
Object.assign(headers, __INIT__.headers)
} }
Object.assign(this.options, __INIT__, options, { url }) if (options.headers) {
Object.assign(headers, options.headers)
delete options.headers
}
Object.assign(this.options, __INIT__, options, { url, headers })
return this.__next__() return this.__next__()
} }