Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const sqlite3 = require('sqlite3').verbose();
- const http = require('http');
- val ADOrequest = function() {
- let db = new sqlite3.Database('./db/chinook.db');
- let sql = 'SELECT PlaylistId id,
- Name name
- FROM playlists
- WHERE PlaylistId = ?';
- let playlistId = 1;
- // first row only
- db.get(sql, [playlistId], (err, row) => {
- if (err) {
- return console.error(err.message);
- }
- return row
- ? console.log(row.id, row.name)
- : console.log(`No playlist found with the id ${playlistId}`);
- });
- db.close();
- return '${row.firstName} ${row.lastName} - ${row.email}';
- }
- http.createServer(function (req, res) {
- res.write(ADOrequest()); //write a response to the client
- res.end(); //end the response
- }).listen(8080);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement