Advertisement
Guest User

Untitled

a guest
Aug 21st, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const sqlite3 = require('sqlite3').verbose();
  2. const http = require('http');
  3.  
  4. val ADOrequest = function() {
  5.     let db = new sqlite3.Database('./db/chinook.db');
  6.     let sql = 'SELECT PlaylistId id,
  7.                  Name name
  8.           FROM playlists
  9.           WHERE PlaylistId  = ?';
  10.     let playlistId = 1;
  11.  
  12. // first row only
  13.     db.get(sql, [playlistId], (err, row) => {
  14.       if (err) {
  15.         return console.error(err.message);
  16.       }
  17.     return row
  18.     ? console.log(row.id, row.name)
  19.     : console.log(`No playlist found with the id ${playlistId}`);
  20.     });
  21.    db.close();
  22.   return '${row.firstName} ${row.lastName} - ${row.email}';
  23. }
  24.  
  25. http.createServer(function (req, res) {
  26.   res.write(ADOrequest()); //write a response to the client
  27.   res.end(); //end the response
  28. }).listen(8080);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement