From b8d1386f04ea7c94a4cd8c1815e00e424cf184bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Correia?= Date: Mon, 29 Aug 2016 15:25:58 +0200 Subject: [PATCH] Allow other file format in the reply. In my case we are trying to fetch csv file format that for some weird reason crowding does not convert to json. --- lib/index.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/index.js b/lib/index.js index 6b1fe51..56cc765 100644 --- a/lib/index.js +++ b/lib/index.js @@ -38,7 +38,14 @@ Crowdin.prototype.requestData = function(params) { }) // Parse JSON .then(function(body) { - if (body) return JSON.parse(body); + if (body) { + try { + return JSON.parse(body); + } + catch (e) { + return body; + } + } return {}; }) // Throw error if present