var mysql = require('mysql');
var pool = mysql.createPool({
connectionLimit : 10,
host : 'example.org',
user : 'bob',
password : 'secret',
database : 'my_db'
});
module.exports = pool;
const pool = require('./file');
const query = 'SELECT 1 + 1 AS solution';
const result = await pool.query(query);
router.post('/signin', passport.authenticate('signin',
{
successRedirect: '/',
failureRedirect: '/login'
}
));
res.render('signin', {
errorMessage: info.message,
user: req.user
});
if user
button(type="submit") signin
button(type="submit") signup
else
h1 Hello #{user.name}
nodemailer.createTransport('smtps://email:password@smtp.mail.ru');
let order = await Order.findOne({orderId: ctx.params.id}, {createdAt: 1, _id: 0}).toArray();
$.ajax({
url: 'create/zakaz',
type: 'POST',
dataType: 'json',
data: {id: 1, userId:2}, //для примера
success: fucntion(data){
},
error: function(err){
}
});
router.post('/zakaz', function(req,res,next){
console.log(req.body);
});
<select id="test">
<option value="tes1t">1</option>
<option value="test2" selected="selected">2</option>
<option value="test3">3</option>
</select>
var sel = document.getElementById("test");
var val = sel.options[sel.selectedIndex].text;
var sel = document.getElementById("test");
var val = sel.options[sel.selectedIndex].value;
var select = $('#test option:selected');
var val = select.val();
$.ajax({
url: 'index.php',
type: 'POST',
data: val,
success: function(data){
//полученный ответ
},
error: function(err){
// ошибка
}
})