karl-common-util
Advanced tools
Comparing version 1.5.8 to 1.5.9
@@ -63,2 +63,8 @@ "use strict"; | ||
case 0: | ||
//如果是浏览器,则自动识别跨域模式 | ||
if (isBrowser && mode === undefined && (url.startsWith("http://") || url.startsWith("https://"))) { | ||
mode === "cors"; | ||
} | ||
promise = new Promise(function _callee(resolve, reject) { | ||
@@ -206,3 +212,3 @@ var json, paramArr, k, v, responese, _responese, status, message; | ||
case 2: | ||
case 3: | ||
case "end": | ||
@@ -239,14 +245,10 @@ return _context2.stop(); | ||
} | ||
//如果是浏览器,则自动识别跨域模式 | ||
if (isBrowser && mode === undefined && (url.startsWith("http://") || url.startsWith("https://"))) { | ||
mode === "cors"; | ||
} | ||
if (!(times > 0)) { | ||
_context3.next = 20; | ||
_context3.next = 19; | ||
break; | ||
} | ||
_context3.prev = 3; | ||
_context3.next = 6; | ||
_context3.prev = 2; | ||
_context3.next = 5; | ||
return regeneratorRuntime.awrap(doFetch({ | ||
@@ -264,9 +266,9 @@ url: url, | ||
case 6: | ||
case 5: | ||
response = _context3.sent; | ||
return _context3.abrupt("return", response); | ||
case 10: | ||
_context3.prev = 10; | ||
_context3.t0 = _context3["catch"](3); | ||
case 9: | ||
_context3.prev = 9; | ||
_context3.t0 = _context3["catch"](2); | ||
@@ -276,7 +278,7 @@ times--; | ||
if (!(times > 0)) { | ||
_context3.next = 19; | ||
_context3.next = 18; | ||
break; | ||
} | ||
_context3.next = 16; | ||
_context3.next = 15; | ||
return regeneratorRuntime.awrap(request({ | ||
@@ -296,9 +298,9 @@ url: url, | ||
case 16: | ||
case 15: | ||
return _context3.abrupt("return", _context3.sent); | ||
case 19: | ||
case 18: | ||
throw _context3.t0; | ||
case 20: | ||
case 19: | ||
case "end": | ||
@@ -308,3 +310,3 @@ return _context3.stop(); | ||
} | ||
}, null, undefined, [[3, 10]]); | ||
}, null, undefined, [[2, 9]]); | ||
}; | ||
@@ -311,0 +313,0 @@ |
{ | ||
"name": "karl-common-util", | ||
"version": "1.5.8", | ||
"version": "1.5.9", | ||
"description": "karl common lib for client and server", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -35,2 +35,8 @@ import "isomorphic-fetch" | ||
let doFetch = async ({url, data = {}, method, timeout = 10000, headers = {}, contentType = "application/json; charset=utf-8", isBrowser = true, withMd5Sign = false, mode}) => { | ||
//如果是浏览器,则自动识别跨域模式 | ||
if (isBrowser && mode === undefined && (url.startsWith("http://") || url.startsWith("https://"))) { | ||
mode === "cors" | ||
} | ||
let promise = new Promise(async (resolve, reject) => { | ||
@@ -143,6 +149,2 @@ //超时reject 408,默认为10秒超时 | ||
} | ||
//如果是浏览器,则自动识别跨域模式 | ||
if (isBrowser && mode === undefined && (url.startsWith("http://") || url.startsWith("https://"))) { | ||
mode === "cors" | ||
} | ||
@@ -149,0 +151,0 @@ if (times > 0) { |
64507