karl-common-util
Advanced tools
Comparing version 1.2.1 to 1.2.2
@@ -63,17 +63,28 @@ "use strict"; | ||
//204和205没有返回内容 | ||
if (!(status === 204 || status === 205)) { | ||
_context.next = 11; | ||
break; | ||
} | ||
resolve({ status: status }); | ||
return _context.abrupt("return"); | ||
case 11: | ||
//将返回结果解析为json | ||
message = void 0; | ||
_context.prev = 9; | ||
_context.next = 12; | ||
_context.prev = 12; | ||
_context.next = 15; | ||
return regeneratorRuntime.awrap(responese.json()); | ||
case 12: | ||
case 15: | ||
message = _context.sent; | ||
_context.next = 19; | ||
_context.next = 22; | ||
break; | ||
case 15: | ||
_context.prev = 15; | ||
_context.t0 = _context["catch"](9); | ||
case 18: | ||
_context.prev = 18; | ||
_context.t0 = _context["catch"](12); | ||
@@ -84,22 +95,24 @@ //结果类型不为json(例如nginx直接返回404错误) | ||
case 19: | ||
case 22: | ||
_context.t1 = status; | ||
_context.next = _context.t1 === 200 ? 22 : _context.t1 === 201 ? 22 : _context.t1 === 202 ? 22 : _context.t1 === 204 ? 22 : _context.t1 === 401 ? 24 : 27; | ||
_context.next = _context.t1 === 200 ? 25 : _context.t1 === 201 ? 25 : _context.t1 === 202 ? 25 : _context.t1 === 204 ? 25 : _context.t1 === 401 ? 27 : 30; | ||
break; | ||
case 22: | ||
case 25: | ||
resolve({ status: status, message: message }); | ||
return _context.abrupt("break", 29); | ||
return _context.abrupt("break", 32); | ||
case 24: | ||
case 27: | ||
//请求未授权,重新登录 | ||
location.href = "../login/"; | ||
if (location !== undefined) { | ||
location.href = "../login/"; | ||
} | ||
reject({ status: 401, message: "重新登录" }); | ||
return _context.abrupt("break", 29); | ||
return _context.abrupt("break", 32); | ||
case 27: | ||
case 30: | ||
reject({ status: status, message: message }); | ||
return _context.abrupt("break", 29); | ||
return _context.abrupt("break", 32); | ||
case 29: | ||
case 32: | ||
case "end": | ||
@@ -109,3 +122,3 @@ return _context.stop(); | ||
} | ||
}, null, undefined, [[9, 15]]); | ||
}, null, undefined, [[12, 18]]); | ||
}); | ||
@@ -112,0 +125,0 @@ return _context2.abrupt("return", promise); |
{ | ||
"name": "karl-common-util", | ||
"version": "1.2.1", | ||
"version": "1.2.2", | ||
"description": "karl common lib for client and server", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -31,2 +31,8 @@ import "isomorphic-fetch" | ||
//204和205没有返回内容 | ||
if (status === 204 || status === 205) { | ||
resolve({status: status}) | ||
return | ||
} | ||
//将返回结果解析为json | ||
@@ -52,3 +58,5 @@ let message | ||
//请求未授权,重新登录 | ||
location.href = "../login/" | ||
if (location !== undefined) { | ||
location.href = "../login/" | ||
} | ||
reject({status: 401, message: "重新登录"}) | ||
@@ -55,0 +63,0 @@ break |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
43210
1007