Javascript 使用Express和Node.js发送两个对象作为对单个GET请求的响应
我有以下代码-Javascript 使用Express和Node.js发送两个对象作为对单个GET请求的响应,javascript,node.js,express,get,response,Javascript,Node.js,Express,Get,Response,我有以下代码- sendServer.get('/download',function(request,response){ var status="SELECT * from poetserver.download where status='0'"; console.log(status) connection.query(status,function(error,rows){ var toSend=rows[0].id response.sendfile('./testi
sendServer.get('/download',function(request,response){
var status="SELECT * from poetserver.download where status='0'";
console.log(status)
connection.query(status,function(error,rows){
var toSend=rows[0].id
response.sendfile('./testimages/'+toSend+'.PNG')
// var details={"pictureId":toSend}
// response.writeHead(200, { 'Content-Type': 'application/json' });
// response.send(JSON.stringify(details));
基本上,我首先希望发送一个由toSend标识的文件。已使用response.sendFile成功发送该文件。但我还想为客户提供一些文件的标识,以备将来的响应。我该如何发送呢?要发送您正在响应的图像资源的id,您应该使用诸如。不要试图在一个响应正文中发送JSON和二进制数据。可能的重复内容应包含在url/uri中。这就是他们的目的。