我正在使用快速会话环回来存储cartId。Loopback模拟会话
但我需要注入cartId请求会话,以使我的测试工作。
所以在我的远程方法我有
Cart.get = function (req, cb) {
Service.getCart(req, req.session.cartId)
.then(function (result) {
cb(null, result);
})
.catch(cb);
};
Cart.remoteMethod(
'get',
{
accepts: { arg: 'req', type: 'object', 'http': { source: 'req' } },
returns: { arg: 'cart', type: 'object', root: true },
http: { path: '/', verb: 'get' }
}
);
如何强制req.session.cartId我的测试?
感谢