From af7c26b163da811a2acfe2d6a8b0fddc71cb07a7 Mon Sep 17 00:00:00 2001 From: cubedro Date: Thu, 12 Feb 2015 07:03:59 +0200 Subject: [PATCH] check request.status in httpsync.js to prevent throwing errors when undefined --- lib/httpsync.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/httpsync.js b/lib/httpsync.js index 06e410c..90f3ee4 100644 --- a/lib/httpsync.js +++ b/lib/httpsync.js @@ -32,13 +32,15 @@ var HttpSyncProvider = function (host) { HttpSyncProvider.prototype.send = function (payload) { //var data = formatJsonRpcObject(payload); - + var request = new XMLHttpRequest(); request.open('POST', this.host, false); request.send(JSON.stringify(payload)); - - // check request.status + var result = request.responseText; + // check request.status + if(request.status !== 200) + return; return JSON.parse(result); };