title: JavaScript convert callback to promise
body: <p>I would like to convert the following callback procedure to a promise. I have the following: </p>
  
  <pre><code>app.get('/api/books', function(req, res)
  {
    let booksCallback = function(books)
    {
      res.send(books)
    }
    DataBase.getBooks(booksCallback)
  
  })
  </code></pre>
  
  <p>And then:</p>
  
  <pre><code>getBooks : function(booksCallback)
  {
    database.ref('/books/').once('value', function(datasnapshot)
    {
      var books = datasnapshot.val()
      booksCallback(books)
  
    });
  }
  </code></pre>
  
  <p>So I'm sending the callback function as a parameter to the function getBooks, which does an async call to Firebase. But is there any way I could do something like <code>Database.getBooks().then(res.send(books))</code>? But then I would need the variable books returned from the async function in getBooks first. Can this be done with a Promise?</p>