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",
"version": "1.0.0",
"version": "1.0.1",
"description": "全新的ajax封装。分2个版本, 一个基于XMLHttpRequest, 一个基于window.fetch",
"main": "dist/index.js",
"directories": {

View File

@ -77,11 +77,18 @@ class _Request {
control.abort()
}
if (__INIT__.headers && options.headers) {
Object.assign(__INIT__.headers, options.headers)
var headers = this.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__()
return this.defer.promise

View File

@ -50,11 +50,18 @@ class _Request {
options.signal = this.control.signal
}
if (__INIT__.headers && options.headers) {
Object.assign(__INIT__.headers, options.headers)
var headers = this.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__()
}