From 3e2fb320293187946fbb1c00ea1918eebea1b186 Mon Sep 17 00:00:00 2001 From: serp Date: Tue, 13 Mar 2018 16:42:38 +0300 Subject: [PATCH] fix collection exec for get type --- lib/collection.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/collection.js b/lib/collection.js index 22f1def..1984b45 100644 --- a/lib/collection.js +++ b/lib/collection.js @@ -48,9 +48,7 @@ var params = { type: execMethodType, - dataType: 'json', - contentType: 'application/json', - processData: false + dataType: 'json' }; // Ensure that we have a URL and add method name to it @@ -60,7 +58,15 @@ } // stringify data to json - if (options.data && _.isObject(options.data)) { + if ( + options.data && + _.isObject(options.data) && + _([ + 'post', 'patch', 'put' + ]).contains((options.type || params.type).toLowerCase()) + ) { + params.processData = false; + params.contentType = 'application/json'; options.data = JSON.stringify(options.data); }