送我有以下的Node.js的代碼:與Express.js後接收的數據通過angular2應用
app.post('/register', function(req, res) {
console.log(req.body);
但看來,REQ對象沒有身體屬性。
隨着angular2我與Content-Type的發送字符串化JSON:應用程序/ JSON
角代碼如下所示:
this.http.post(
"http://url.com",
JSON.stringify(data_obj), {headers:{'Content-Type':
'application/json'}}).subscribe((res:Response) => this.extractData(res));
感謝
您是否在快速服務器中安裝了任何中間件?說:express [bodyparser](https://github.com/expressjs/body-parser)? – Gimby
不,節點說這個中間件不再與express捆綁在一起,必須單獨安裝 – Maxim
yea,但是你仍然需要像提到的@Gimby那樣解析body。 –