{
answear(ids) {
return new Promise((resolve, reject) => {
const bindings = ids.map(id => '?').join(',');
db.query(
`SELECT * FROM answers WHERE id_question IN (${bindings})`,
ids,
(error, rows) => {
if (error) {
return reject(error);
}
resolve(rows);
}
);
});
}
}
HTTP.defaults.headers.common['Authorization'] = `Bearer ${token}`;
const chat = io.connect(config.wssHost);
// Иначе при переподключении будут дублироваться
chat.on('connect', function() {
console.log('Connected');
});
chat.on('message', function(message){
console.log(message);
});
io.on('connection', function (socket) {
socket.on('message', function (data) {
//socket.broadcast.emit('message', data); // (1)
console.log(data);
io.sockets.emit('message', data);
});
});
.on('response', (response) => {
let body = '';
response.on('data', (chunk) => {
body += String(chunk);
});
response.on('end', () => {
body = JSON.parse(body);
console.log(body);
});
})
query {
users(first: 10, order: "id") {
totalCount,
edges {
cursor,
node {
id,
name,
lastAt,
avatar {
original,
preview
}
}
},
pageInfo {
startCursor,
endCursor,
hasNextPage,
hasPreviousPage
}
}
}
var MyCode = (function($){
function MyCode () {
// constructor
}
MyCode.prototype.one = function(){
// code
};
MyCode.prototype.two = function(){
// code
};
return MyCode;
})(window.jQuery);
var myCodeInstance1 = new MyCode;
var myCodeInstance2 = new MyCode;
myCodeInstance1.one();
myCodeInstance1.two();
myCodeInstance2.one();
myCodeInstance2.two();