FACK1 / fid-or

0 stars 1 forks source link

database queries #19

Open shahenazmonia opened 5 years ago

shahenazmonia commented 5 years ago

It would be better if you put database query in a seprate file

const onLoad = (request, response) =>{
  //get data from the database
  dbConnection.query('SELECT * FROM tododb', (err, result) => {
    if (err) {
      console.log("Error")
      console.log(err);
    } else {
        console.log(result);
        response.writeHead(200, {"content-type":"application/json"})
        response.end(JSON.stringify(result.rows));
    }
  });