Skip to content

database queries #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
shahenazmonia opened this issue Dec 6, 2018 · 0 comments
Open

database queries #19

shahenazmonia opened this issue Dec 6, 2018 · 0 comments

Comments

@shahenazmonia
Copy link

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));
    }
  });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant