title: How to pass information to view from controller in NODE JS Express
body: <p>I'm quite new to NodeJS. I'm trying to create a form that accepts several inputs. One of the functions of the form is to take in an input--> ISBN and automatically get information from an API and add it in the input fields. However, I cannot pass information from the controller to the view.</p>
  
  <p>I have a view: <code>newbook.jade</code> 
  Which has two forms</p>
  
  <pre><code> form#form_search_book(name="search", method="post", action="/searchbook")
      span ISBN
      span &amp;nbsp;
      input#input_isbn(type="text", placeholder="isbn", name="isbn")
      button#search_book(type="search") search
      br
      br
    form#form_add_book(name="addbook", method="post", action="/addbook")
      span Book Name
      span &amp;nbsp;
      input#input_name(type="text", placeholder="book name", name="book_name")
  </code></pre>
  
  <p>And I have the NodeJS controller: <code>index.js</code> that executes the /searchbook form and then redirects back the /newbook page. When it redirects to the new book page, the information from the API should be passed on to the input form...but I've been struggling on how to do that. 
  Any help would be appreciated.</p>
  
  <pre><code>    router.get('/newbook', function(req, res){
      res.render('newbook', {title: 'Add New Book' });
  
      router.post('/searchbook', function(req, res){
      var isbn=req.body.isbn;
      var url="http://isbndb.com/api/v2/json/63JEP95R/book/"+isbn;
      request({
      url: url,
      json: true
      }, function (error, response, body) {
            if (!error &amp;&amp; response.statusCode === 200) {
                  console.log(body.data\[0\].isbn13) // Print the json response
                }
      });
      res.redirect('/newbook');
      document.getElementById('input_name').value=body.data\[0\].title;
      document.getElementById('input_isbn').value=body.data\[0\].isbn13;
  
  
      });
  });
  </code></pre>
  
  <p><a href="http://i.stack.imgur.com/leATl.png" rel="nofollow">Link to the view</a></p>