I am trying to include underscore.js in my parse cloud code as below
require('cloud/underscore.js');
And this is the code that use its function
var uniqTest = _.uniq([1,5,4,4,5,2,1,1,3,2,2,3,4,1]);
response.success(uniqTest);
But it's giving me following response
{
"code": 141,
"error": "ReferenceError: _ is not defined\n at main.js:146:20"
}
Any idea why?
To make it more obvious for others and to give you a chance to mark this as answered :)
It looks like the variable _
is not assigned.
You try to execute uniq on _
and since _
seems not to be defined _.uniq
will not work. Try to do var _ = require('cloud/underscore.js');