node-rest-client icon indicating copy to clipboard operation
node-rest-client copied to clipboard

TypeError: props[propIndex].split is not a function

Open xerxesb opened this issue 8 years ago • 10 comments

Hi,

I recently updated from v1.8 to v3.1 to pull a JSON object from a Google Sheets script via a few redirects.

I'm now getting the following error when trying to hit the endpoint. Appreciate any help.

TypeError: props[propIndex].split is not a function at validateProperties (/Users/dev/Documents/src/app/node_modules/node-rest-client/lib/nrc-parser-manager.js:10:39) at Object._private.validate (/Users/dev/Documents/src/app/node_modules/node-rest-client/lib/nrc-parser-manager.js:21:13) at add (/Users/dev/Documents/src/app/node_modules/node-rest-client/lib/nrc-parser-manager.js:34:17) at module.exports (/Users/dev/Documents/src/app/node_modules/node-rest-client/lib/nrc-parser-manager.js:112:15) at new exports.Client (/Users/dev/Documents/src/app/node_modules/node-rest-client/lib/node-rest-client.js:12:53) at Object.getClient (/Users/dev/Documents/src/app/src/js/staff_calendar.js:28:25) at Object.fetchData (/Users/dev/Documents/src/app/src/js/staff_calendar.js:8:35) at staff_leave (/Users/dev/Documents/src/app/routes/index.js:211:9) at callbacks (/Users/dev/Documents/src/app/node_modules/express/lib/router/index.js:164:37) at param (/Users/dev/Documents/src/app/node_modules/express/lib/router/index.js:138:11)

Thanks.

xerxesb avatar Apr 18 '17 13:04 xerxesb

did you fix that? i am stuck with the same problem...

ghost avatar Jul 04 '17 23:07 ghost

Same problem here. Anyone know how to fix?

hExPY avatar Aug 24 '17 21:08 hExPY

Same problem :(

nanthanwa avatar Sep 18 '17 06:09 nanthanwa

same problem !!!!!!!!!!!!!!!

droidmanspace avatar Jan 12 '18 20:01 droidmanspace

same problem !!!!!!!!!! ! ! ! ! ! !!!!!

ivan-mezentsev avatar Mar 06 '18 20:03 ivan-mezentsev

Check your Array.prototype scope, it's probably polluted. e.g. if you hava Array.prototype.something = function() {...} for(var x in ['a']) will return something as the last element, which node-rest-client is not expecting.

mattdawson avatar May 13 '18 23:05 mattdawson

@mattdawson thanks; i had added Array.prototype.random() and turns out for (var x in ['a']) included random.

ghost avatar Oct 08 '19 23:10 ghost

@mattdawson but why node-rest-client depends on what user do with Array or Object prototype ?

maroodb avatar Nov 04 '19 07:11 maroodb

@maroodb i think because when you simply assign a new property like Array.prototype.random = ... it creates an enumerable property on all instances of Array, so when you iterate over an array's values with a for...in loop, it includes the inherited property you added. The built-in Array methods are not enumerable, so to properly extend the Array class you have to define it as not-enumerable too:

Object.defineProperty(Array, "random", {
    value: function () {...},
    enumerable: false
});

ghost avatar Nov 04 '19 18:11 ghost

@ledlamp I think to avoid those type of problems when we develop a library we shouldn't depends on user manipulations, thank's

maroodb avatar Nov 05 '19 10:11 maroodb