Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 如何从MongoDB返回对象_Node.js_Mongodb - Fatal编程技术网

Node.js 如何从MongoDB返回对象

Node.js 如何从MongoDB返回对象,node.js,mongodb,Node.js,Mongodb,我需要使用HTTP GET在Node Js中找到API的所有文档,但响应不是对象 我的代码: app.get ('/altas', (req, res) => { /*Trae la info de la base de datos*/ MongoClient.connect (url, { useNewUrlParser: true, useUnifiedTopology: true }, (err, db) => { if (e

我需要使用HTTP GET在Node Js中找到API的所有文档,但响应不是对象

我的代码:

app.get ('/altas', (req, res) => {

/*Trae la info de la base de datos*/
    MongoClient.connect (url, { 
        useNewUrlParser: true, useUnifiedTopology: true }, (err, db) => {
            if (err) throw err;
            dbo = db.db ("uade-clase-36");
        dbo.collection ('api_autos_emilio').findOne({}, (err, result) => {
        if (err) throw err;
        db.close();
    });
}); 
}))

错误/响应:

_eventsCount: 2,
      _maxListeners: undefined,
      _connections: 1,
      _handle: [TCP],
      _usingWorkers: false,
      _workers: [],
      _unref: false,
      allowHalfOpen: true,
      pauseOnConnect: false,
      httpAllowHalfOpen: false,
      timeout: 120000,
      keepAliveTimeout: 5000,
      maxHeadersCount: null,
      headersTimeout: 60000,
      _connectionKey: '6::::3000',
      [Symbol(IncomingMessage)]: [Function: IncomingMessage], ... THIS NOT THE END.