aacerox / node-rest-client

REST API client from node.js
MIT License
377 stars 132 forks source link

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

Open xerxesb opened 7 years ago

xerxesb commented 7 years ago

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.

ghost commented 7 years ago

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

hExPY commented 7 years ago

Same problem here. Anyone know how to fix?

nanthanwa commented 7 years ago

Same problem :(

droidmanspace commented 6 years ago

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

ivan-mezentsev commented 6 years ago

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

mattdawson commented 6 years ago

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.

ghost commented 5 years ago

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

maroodb commented 5 years ago

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

ghost commented 5 years ago

@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
});
maroodb commented 5 years ago

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