daily pastebin goal
27%
SHARE
TWEET

Untitled

a guest May 23rd, 2018 91 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var mysql = require('mysql');
  2.  
  3. exports.helloGET = (req, res) => {
  4.  
  5. console.log(req.body.message);
  6.  
  7. var con = mysql.createConnection({
  8.       //socketPath: '/cloudsql/' + 'project-id:region-name:instance',
  9.       host: 'xxx.xxx.xxx.xxx',
  10.       user: 'user',
  11.       password: 'root',
  12.       database: 'test'
  13.     });
  14.  
  15.     con.connect(function(err) {
  16.         console.log("Connection Error - " + err)
  17.         if (err) throw err;
  18.         console.log("Connected to Cloud SQL");
  19.     });
  20.  
  21.     con.query(`SELECT now()`, null, function (err, result) {
  22.         //made reply here
  23.         console.log("Query Error - " + err)
  24.         if (err) throw err;
  25.         console.log("Result: " + result);
  26.     });
  27.  
  28. con.end();
  29. res.status(200).send('Acknowledgement : ' + req.body.message);
  30. };
  31.    
  32. var con = mysql.createConnection({
  33.       socketPath: '/cloudsql/' + 'project-id:region-name:instance',
  34.       //host: 'xxx.xxx.xxx.xxx',
  35.       user: 'user',
  36.       password: 'root',
  37.       database: 'test'
  38.     });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top