{"id":5877,"date":"2014-04-07T23:41:02","date_gmt":"2014-04-07T23:41:02","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/04\/07\/unexpected-token-node-js-eval-a-functtion-collection-of-common-programming-errors\/"},"modified":"2014-04-07T23:41:02","modified_gmt":"2014-04-07T23:41:02","slug":"unexpected-token-node-js-eval-a-functtion-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/04\/07\/unexpected-token-node-js-eval-a-functtion-collection-of-common-programming-errors\/","title":{"rendered":"Unexpected token ) node js eval a functtion-Collection of common programming errors"},"content":{"rendered":"<p>I am storing a function in my database and retrieving it from the database with node.js<\/p>\n<p>When I <code>console.log<\/code> the column containing the function this is the output<\/p>\n<pre><code>(function(settings){var options = {host: 'somehost.com',path: 'some\/path\/' + settings.token + '?mobile=' + settings.number + '&amp;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();})\n<\/code><\/pre>\n<p>When I <code>console.log<\/code> <code>typeof<\/code> column it prints out <code>string<\/code><\/p>\n<p>But when I do<\/p>\n<pre><code>var func = eval(column);\n<\/code><\/pre>\n<p>It results in <code>Unexpected token )<\/code><\/p>\n<p>Does anyone know why?<\/p>\n<p>I have made my function smaller now:<\/p>\n<pre><code>function(settings){var options = {host: 'api.smsmonster.co.za',path: '\/uv1.svc\/SendSMS\/' + settings.token + '?mobile=' + settings.number + '&amp;message=' + settings.message}settings.httpRequest.request(options, settings.callback).end();}\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>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: &#8216;somehost.com&#8217;,path: &#8216;some\/path\/&#8217; + settings.token + &#8216;?mobile=&#8217; + settings.number + &#8216;&amp;message=&#8217; + settings.message};callback = (function(response) {var str = &#8221;;response.on(&#8216;data&#8217;, (function (chunk) {str += chunk;}));response.on(&#8216;end&#8217;, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-5877","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5877","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=5877"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5877\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=5877"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=5877"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=5877"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}