Unexpected token ) node js eval a functtion-Collection of common programming errors
I am storing a function in my database and retrieving it from the database with node.js
When I console.log
the column containing the function this is the output
(function(settings){var options = {host: 'somehost.com',path: 'some/path/' + settings.token + '?mobile=' + settings.number + '&message=' + settings.message};callback = (function(response) {var str = '';response.on('data', (function (chunk) {str += chunk;}));response.on('end', (function () {settings.result(str);})));}settings.httpRequest.request(options, callback).end();})
When I console.log
typeof
column it prints out string
But when I do
var func = eval(column);
It results in Unexpected token )
Does anyone know why?
I have made my function smaller now:
function(settings){var options = {host: 'api.smsmonster.co.za',path: '/uv1.svc/SendSMS/' + settings.token + '?mobile=' + settings.number + '&message=' + settings.message}settings.httpRequest.request(options, settings.callback).end();}