[英]Http.request results in TypeError: “values is null”
我正在尝试从本地存储执行已保存的请求。
这是负责发送请求的代码:
public sync() {
this.setSyncState(SyncState.Syncing)
Array.from(this.stateManager.entries()).forEach(([key, value]) => {
let newRequest: HttpRequest<any> = { ...value }
this.http.request(
newRequest.method,
newRequest.urlWithParams,
{
body: newRequest.body,
headers: newRequest.headers,
params: newRequest.params,
reportProgress: newRequest.reportProgress,
responseType: newRequest.responseType,
withCredentials: newRequest.withCredentials
}
).subscribe(
event => {
if (event instanceof HttpResponse) {
this.stateManager.delete(key)
console.log("Request from cache succeeded")
}
},
error => {
console.log("Request from cache failed", error)
}
)
})
if (Array.from(this.stateManager.entries()).length < 0) {
this.setSyncState(SyncState.Synced)
} else {
this.setSyncState(SyncState.SyncFailed)
}
}
stateManager.entries()将本地存储中的已保存请求作为Map返回。
谁能指出我的方向? 我似乎找不到错误的根源。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.