app.post('/', (req, res) => {
conn.query("SELECT `fio` FROM `students` WHERE `id`=1",function(error,result){
if (error) throw error;
res.send(result.map(item => item));
});
});
var query = conn.query("SELECT `fio` FROM `students` WHERE `id`=1",function(error,result){
if (error) throw error;
console.log(result);
});
async function getData(url) {
url instanceof String && url.length ? url : '/';
const options = {
method: 'POST',
headers: {
'Content-Type' : 'application/json'
}
};
let response = await fetch(url, options);
let data = await response.json();
return data;
}
const data = getData();
console.log(data);
const express = require('express');
const mysql = require('mysql');
const app = express();
console.log('Get connection ...');
var conn = mysql.createConnection({
database: 'university',
host: "localhost",
user: "aaa",
password: "aaa"
});
conn.connect();
app.post('/', (req, res) => {
conn.query("SELECT `fio` FROM `students` WHERE `id`=1",function(error,result){
if (error) throw error;
console.log(result);
res.send(result.map(item => item));
});
});
app.listen(96);
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
</head>
<body>
<script src="client.js"></script>
</body>
</html>
async function getData(url) {
url instanceof String && url.length ? url : '/';
const options = {
method: 'POST',
headers: {
'Content-Type' : 'application/json'
}
};
let response = await fetch(url,options);
let data = response.json();
return data;
}
const data = getData('http://test1.ru:96/'); //?
console.log(data);
const express = require('express');
const mysql = require('mysql');
const app = express();
console.log('Get connection ...');
var conn = mysql.createConnection({
database: 'university',
host: "localhost",
user: "aaa",
password: "aaa"
});
conn.connect();
app.post('/', (req, res) => {
conn.query("SELECT `fio` FROM `students` WHERE `id`=1",function(error,result){
if (error) throw error;
res.send(result.map(item => item));
});
});
app.listen(96);