From b1bf064c9d38e51c7e5621cc04ed508c553793ff Mon Sep 17 00:00:00 2001 From: huoyanwuzhe629 Date: Mon, 22 Jan 2018 17:05:13 +0800 Subject: [PATCH] =?UTF-8?q?res=E4=B8=BAundefined=E7=9A=84=E5=AE=B9?= =?UTF-8?q?=E9=94=99=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit res为undefined的容错处理 --- src/biz-mock.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/biz-mock.js b/src/biz-mock.js index bf39aa1..bf10fb3 100644 --- a/src/biz-mock.js +++ b/src/biz-mock.js @@ -313,7 +313,8 @@ Mock.prototype._getServerData = function(configs, url, req, res, cb) { logger.info('request headers:', JSON.stringify(headers)); request(options, function(error, res, body) { //若响应码在配置的列表中,则返回结果,否则使用其他mock源的数据 - if (statusCodeList.indexOf(res.statusCode) > '-1') { + var statusCode = res ? res.statusCode : null; + if (statusCodeList.indexOf(statusCode) > '-1') { cb(error, body) } else { cb(error);