【发布时间】:2019-03-07 12:34:19
【问题描述】:
我有一个非常基本的问题,但我不知道最好的方法。我的问题在于单击要发送数据并从服务器获取相同数据的按钮。在某些情况下,我的后端可以有时间将数据存储在我的数据库中,当我检索数据时,我会在没有最后更改的情况下提取数据。
storeCategory() {
this.categoryService.storeCategory(this.currentFileUpload, this.category).subscribe();
this.adminService.getCategoryFromServer();
有人知道有提议吗?
【问题讨论】:
-
您的服务器能否将该数据作为对第一个请求的响应返回?
-
为此,我可以在后端更改我的方法。 Maby 就是一个很好的解决方案。
-
如果你能做到,我认为这是最简单和最安全的解决方案
-
谢谢,我想是的。
-
您也可以在 storeCategory() 之后管道并执行 getCategoryFromServer ,即 this.categoryService.storeCategory(this.currentFileUpload, this.category).pipe(map(() => this.adminService.getCategoryFromServer( )).subscribe((数据) => 数据)
标签: angular http observable