从Express JS调用返回数据(使用Fetch)

我正在从我的数据库请求我的客户端数据,但是我无法在调用时返回数据。 如果我改变res.write()的响应方法,我的数据显示在页面上,但我需要返回到一个variables,而不是作为JSON。 我在下面列出了我的服务器和客户端代码。

服务器端代码:

  app.get('/t',function(req,res){ var connection = mysql.createConnection({host:'*****', user: '****', password: '****', database: '****'}); connection.query('SELECT * FROM apron', function (err, results, fields) { res.json(results); // results contains rows returned by server connection.end(); }); 

前端代码(Fetch):

 fetch('\t').then(function(result){ return result.json(); }).then(function(r){ console.log(r); });