title: Passing data to view in node + express
body: <p>I'm using my node app to retrieve some data from an API and want to display that data in a view and allow the user to change it there. I'm calling the api and get a JSON response which I'd like to pass onto the view. Here's what I'm doing:</p>
  
  <pre><code>    var query = 'SELECT Id, OwnerId, ActivityDateTime, EndDateTime, WhatId, WhoId, Subject FROM Event WHERE OwnerId = \'' + user.userId + '\''  ;
      // execute the query and get response
      ...
      ...
      var ev = resp.records;
      res.render('index.html', {eventData : ev});
  </code></pre>
  
  <p>Problem being that when I then want to use the data in my view, I get an undefined error.</p>
  
  <p>If I do:</p>
  
  <pre><code>    &lt;div id='Subject'&gt;#{eventData.Subject}&lt;/div&gt;
  </code></pre>
  
  <p>I get a print-out of #{eventData.Subject}</p>
  
  <p>Trying to use the data in JS returns an undefined error:</p>
  
  <pre><code>    &lt;script type="text/javascript"&gt;
      var mydata = #{eventData};
      &lt;/script&gt;
  </code></pre>
  
  <p>After some searching I found a post that suggested to stringify it first:</p>
  
  <pre><code>    var mydata = !{JSON.stringify(eventData)};
      console.log(mydata);
  </code></pre>
  
  <p>Here, I get a syntax error "SyntaxError: missing : after property id"</p>
  
  <p>I'm pretty sure I'm missing something basic and can't for the life of me figure it out. I've found a lot of articles examples that explain how to do it in Jade, but I don't want to use Jade and using the recommendations from the articles results in "undefined" or "illegal character" errors.</p>
  
  <p>I'm all out of ideas... help?
  Tnx</p>