From b022ae165fd1e521ac0fafbffbfd8c54edf07e7c Mon Sep 17 00:00:00 2001 From: Shawn Lim Date: Fri, 15 May 2015 01:52:08 +0800 Subject: [PATCH] set headers for both errors and success --- libs/fetcher.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libs/fetcher.js b/libs/fetcher.js index a75c98e9..9e31421f 100644 --- a/libs/fetcher.js +++ b/libs/fetcher.js @@ -101,14 +101,14 @@ function parseParamValues (params) { params: parseParamValues(qs.parse(path.join('&'))), config: {}, callback: function (err, data, meta) { - if (err) { - res.status(err.statusCode || 400).send(err.message || 'request failed'); - return; - } meta = meta || {}; if (meta.headers) { res.set(meta.headers); } + if (err) { + res.status(err.statusCode || 400).send(err.message || 'request failed'); + return; + } res.status(meta.statusCode || 200).json(data); } };