When I try to split a string in node I get the following error…
TypeError: Object #<Object> has no method 'split'
Here is the split code I am using…
var query = req.query;
query.split(",");
I am using express to create my server, it seems like it is looking for a module, but isn’t .split() a standard method with node.js?
req.querysimply isn’t a string; it’s an object, created by parsing the query string inreq.urlinto key-value pairs. Therefore it doesn’t have asplitmethod, since that’s only for strings. If you need the literal text of the query string (like because it’s not actually made up of key-value pairs), useurl.parse(req.url).query.