【发布时间】:2020-07-14 19:00:03
【问题描述】:
// any component
async submit(value: any) {
await this.guildService.saveGuild(this.guild.id, value);
}
...
// guild.service.ts
saveGuild(id: string, value: any) {
return this.http.put(`${this.endpoint}/${id}?key=${this.key}`, value).toPromise();
}
API 路由
router.put('/:id', async (req, res) => {
try {
const id = req.params.id;
validateGuildManager(req.query.key, id);
const updatedGuild = await SavedGuild.findByIdAndUpdate(id, req.body).lean();
res.json(updatedGuild);
} catch { res.status(400).send('Bad Request'); }
});
我尝试了许多不同的 value 组合,但 API 上未定义正文。
回购:https://github.com/theADAMJR/2pg-dashboard - 不包括提交,但问题仍然存在
【问题讨论】:
标签: node.js angular typescript http