查询 $resource 和 GridFS

Querying $resource and GridFS

我在客户端获取查询响应时遇到问题。显然,服务器端工作正常。

这是服务器端查询的样子:

gfs.files.find({
    "metadata.owner": req.params.driver
}).toArray(function(err, files) {
    if (err) {
        return handleError(err);
    }
    console.log(files); /* files contents the correct result */
    return files;
});

这是我的客户端,我没有得到结果:

GridFS.query({
    driver: user._id
}, function(err, res) {
    if (err) {
        console.log(err);
    }
    console.log(res); /* nothing here*/
});

实际上,在我刷新页面之前我没有收到任何错误,当我得到这个时:

Possibly unhandled rejection: {"data":null,"status":-1,"config":{"method":"GET","transformRequest":[null],"transformResponse":[null],"jsonpCallbackParam":"callback","url":"/api/gridfs/5978d197b24dfa0f87160617","headers":{"Accept":"application/json, text/plain, */*","Authorization":"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI1OTc4ZDE5N2IyNGRmYTBmODcxNjA2MTciLCJyb2xlIjoiZHJpdmVyIiwiaWF0IjoxNTAxNDEyMzI1LCJleHAiOjE1MDE0MzAzMjV9.EWCQ6jm_uXe1KQIhMaqnIff8UUeMZfUV8CZfeDI95qk"}},"statusText":""}  vendor.bundle.js:14487:19

我刚刚忘记发送回复:

return res.send(files);