search

Home  >  Q&A  >  body text

node.js - 为什么 mocha request 异步 返回的是空值?

nodejs 下,用 mocha 没办法异步获取到接口的值,返回是[],是怎么回事?

测试代码:

 it('index', function (done) {
            request.get('/v1/user')
                .end(function (err, res) {
                    console.log(res.text);
                    done();
                });
        });

控制器代码:

router.get('/', async (req: Request, res: Response) => {
    let model = await getConnection().getRepository(User).find();
    res.send(model);
});
PHP中文网PHP中文网2786 days ago450

reply all(1)I'll reply

  • 天蓬老师

    天蓬老师2017-04-17 16:11:28

    The database connection is wrong

    reply
    0
  • Cancelreply