this.projectService.removeProject(projectId).subscribe(() => {
console.log('deleted');
})
服务电话看起来像:
removeProject(id: number) {
return this.httpClient.delete(`/api/projects/${id}`)
}
其中httpClient是:
constructor(private httpClient: HttpClient)
这一切都运行正常,直到我从4.3升级到4.4并且我现在得到了:
ERROR TypeError: You provided 'undefined' where a stream was expected. You can provide an Observable, Promise, Array, or Iterable.
at Object.subscribeToResult (subscribeToResult.js:73)
at CatchSubscriber.webpackJsonp.../../../../rxjs/operator/catch.js.CatchSubscriber.error (catch.js:111)
at XMLHttpRequest.onLoad (http.es5.js:1729)
at ZoneDelegate.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:425)
at Object.onInvokeTask (core.es5.js:3881)
at ZoneDelegate.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:424)
at Zone.webpackJsonp.../../../../zone.js/dist/zone.js.Zone.runTask (zone.js:192)
at ZoneTask.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneTask.invokeTask [as invoke] (zone.js:499)
at invokeTask (zone.js:1427)
at XMLHttpRequest.globalZoneAwareCallback (zone.js:1445)
我刚刚将其归结为以下内容。我的删除功能返回200响应状态:
[HttpDelete("{id}")]
public void Delete(int id)
{
_projectRepository.Delete(id);
}
如果我让它返回一些东西(只是为了证明),那么它确实可以正常工作:
[HttpDelete("{id}")]
public Project Delete(int id)
{
_projectRepository.Delete(id);
return new Project();
}
这是一个纯粹来自升级的新问题。大概有些事情变得更严格但我不确定如何处理?
答案 0 :(得分:0)
好的,所以似乎返回了204 No Content就可以了。
我不确定200不工作的逻辑/推理是什么。如果有人可以更新会很好。
有效的代码(C#):
.*