node.js - 为什么 mocha request 异步 返回的是空值?
PHP中文网
PHP中文网 2017-04-17 16:09:28
0
1
409

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中文网

认证高级PHP讲师

reply all (1)
Peter_Zhu

数据库接错了

    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!