我试图在我的“实验室交换”数据中添加一个“createdBy”属性,并将其填充到经常帐户电子邮件中。
在服务器上的实验室交换服务的“create”函数中,我尝试添加帐户数据,但是控制台中的“email”始终是“未定义”的。我可能没有使用正确的语法,或者没有从角前端发送“帐户”信息?
(前端)实验室服务:
create(params: any, account: Account) { //do I need "account" here?
return this.http.post(baseUrl, params);
}(后端)实验室-swap.service.js:
async function create(account, params) { //do I need "account" here?
const labSwap = new db.LabSwap(account, params);
labSwap.verified = Date.now();
labSwap.createdBy = this.account.email; //whats correct syntax to use?
// save labSwap table
await labSwap.save();
}lab-swap.controller.js:
function create(req, res, next) {
labSwapService.create(req.body)
.then(() => res.json({ message: 'Lab Swap created' }))
.catch(next);
}发布于 2022-04-19 00:08:22
通过在前端表单中添加一个新字段并设置帐户电子邮件,解决了我的问题:
createdBy: [this.account.email],https://stackoverflow.com/questions/71917083
复制相似问题