socket.on("connect_error", (e) => {
console.log('ERROR', e)
});
const socket = io("https://example.com"); // the main namespace
const productSocket = io("https://example.com/product", { forceNew: true }); // the "product" namespace
const orderSocket = io("https://example.com/order", { forceNew: true }); // the "order" namespace
io.sockets.on('connection', function (socket) {
console.log('hello: ' + socket.id) // ЭТО ВЫВОДИТСЯ ДВАЖДЫ
})
const io = require('socket.io-client')
const socket = io("http://localhost:1900", {
transports: ["websocket"]
})
socket.on("connect", (socket) => {
console.log('CONNECT SOCKET', socket) // ЭТО В КОНСОЛЬ НЕ ВЫВОДИТСЯ
});
app.post('/register', async (req, res) => {
try {
const { body } = req
await checkUniqueEmail(body.email, function (isUniqueEmail) {
if (!isUniqueEmail) {
res.json({
status: 'error',
title: 'E-Mail адрес занят',
text: 'Используйте другой',
})
return
}
res.json({
status: 'success',
})
})
} catch (err) {
console.error(err)
}
});
function checkUniqueEmail (email, callback) {
pool.connect((err, client, done) => {
if (err) throw err
client.query('SELECT * FROM users WHERE email = $1', [email], (err, res) => {
done()
if (err) {
console.log(err)
} else {
return callback(res.rowCount === 0)
}
})
})
}