当我尝试注销时出现此错误。
`core.js:6014 ERROR TypeError: Cannot read property 'length' of undefined
at http.js:165
at Array.forEach (<anonymous>)
at HttpHeaders.lazyInit (http.js:153)
at HttpHeaders.init (http.js:274)
at HttpHeaders.forEach (http.js:376)
at Observable._subscribe (http.js:2342)
at Observable._trySubscribe (Observable.js:42)
at Observable.subscribe (Observable.js:28)
at subscribeTo.js:20
at subscribeToResult (subscribeToResult.js:7)`
Run Code Online (Sandbox Code Playgroud)
但是当我从邮递员发送 HTTP 请求时,代码就可以工作了。我在使用邮递员时成功退出
我的认证服务
`logout(user){
let headers = new HttpHeaders({
'Content-Type': 'application/json',
'Authorization': this.token }); //this.token is the value of token(eyJhbGciOiJIUzI1NiIsInR5cCI6IkpX...)
let options = { headers: headers };
localStorage.clear()
this.token=null;
return this.http.post<response>('http://localhost:3000/users/logout',null,options).pipe(map(res=>{
console.log(res)
return res
}))}
Run Code Online (Sandbox Code Playgroud)
` 这是我订阅此 http 请求的代码:
onLogout(){ …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 Visual Studio Code IDE 在我的 PC 中运行下载的离子模板,但当我尝试运行时出现以下错误npm install
> grpc@1.20.0 install C:\Users\Lenovo\Desktop\project\Template-Ionic\ionic-starter-master\node_modules\grpc
> node-pre-gyp install --fallback-to-build --library=static_library
node-pre-gyp WARN Using request for node-pre-gyp https download
node-pre-gyp WARN Tried to download(404): https://node-precompiled-binaries.grpc.io/grpc/v1.20.0/node-v72-win32-x64-unknown.tar.gz
node-pre-gyp WARN Pre-built binaries not found for grpc@1.20.0 and node@12.14.1 (node-v72 ABI, unknown) (falling back to source compile with node-gyp)
gyp ERR! find VS
gyp ERR! find VS msvs_version was set from command line or npm config
gyp ERR! find VS - looking for Visual Studio version …Run Code Online (Sandbox Code Playgroud) 处理作为错误或通知显示给客户端的消息字符串的最佳实践是什么,以便在打字稿方面和 htlm 中都没有硬代码?
例如,它发生在我身上:在 html 中:
<h1> {{header_message}} </h1>
Run Code Online (Sandbox Code Playgroud)
在打字稿中:
let notificationInfo: string = 'notifications.infoMessage';
Run Code Online (Sandbox Code Playgroud)