From a63e7cd8ca20b613db4a4b11b664ad67ecc997c2 Mon Sep 17 00:00:00 2001 From: Michael Bradley Date: Fri, 26 Feb 2016 08:55:54 -0800 Subject: [PATCH] Fix for https://github.com/mzabriskie/axios/issues/248 undefined is not valid JSON, make the value null instead. JSON.parse(undefined) will throw an exception while JSON.parse(null) is acceptable. http://stackoverflow.com/a/14946821/5012948 --- lib/adapters/xhr.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/adapters/xhr.js b/lib/adapters/xhr.js index c930f2e..6c02294 100644 --- a/lib/adapters/xhr.js +++ b/lib/adapters/xhr.js @@ -125,6 +125,9 @@ module.exports = function xhrAdapter(resolve, reject, config) { requestData = new DataView(requestData); } + // Clean up request + requestData = requestData === undefined ? null : requestData; + // Send the request request.send(requestData); };