我通过一个按钮从客户端向我使用 express 创建的服务器发出请求,在请求处理程序中只有 console.log('Delete from server'); 每次我点击它我都会收到这些错误
angular2.dev.js:23514 ORIGINAL EXCEPTION: T
ypeError: Cannot read property 'request' of undefined
angular2-polyfills.js:143 Uncaught EXCEPTION:
Error during evaluation of "click"
ORIGINAL EXCEPTION: TypeError: Cannot read property 'request' of undefined
ORIGINAL STACKTRACE:
文件结构是,有两个文件夹 server 和 client 分别有 angular 和 server 文件
这是按钮单击的功能:
deletefromserver(){
this.http.request("http://localhost:3000/deletedata").subscribe((res : Response) => {
console.log(res.json());
})
}
这是服务器文件中的请求处理程序:
server.get('/deletedata', function(){
console.log('Delete from server');
})