Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module.exports = function(app){
- app.get("/produtos", function(req, res) {
- var mysql = require("mysql");
- var connection = mysql.createConnection({
- host: "localhost",
- user: "root",
- password: "",
- database: "casadocodigo_nodejs"
- });
- connection.connect(function(err) {
- if (err) {
- console.error('error connecting: ' + err.stack);
- return;
- }
- console.log('connected as id ' + connection.threadId);
- });
- connection.query("select * from livros", function(err, results) {
- res.send(results);
- });
- connection.end();
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement