node.js - angular2-rc1 http.post not working correctly -
i creating 1 angular2 app in using http in service make post
call mongodb
.
when making post
call first time working fine i.e. entry inserted database correctly when sending data second time not getting inserted.
if reloading page after first insertion working fine.
i did debugging , found during second request req.body
blank.
here code:
page.service.ts
savepage(page: object) { this.headers.append('content-type', 'application/json'); let url = this.baseurl+'/pm/pages/'; let data={}; data["data"]=page; console.log(data); //this printing both times correctly //on second request data blank works correctly first time return this.http.post(url, json.stringify(data),{headers: this.headers}) .map((res: response) => res.json()).catch(this.handleerror); }
here data in req.body shown in node services.
first request:
body:{ data:{ name: 'wtwetwet', desc: 'wetwetwetetwte', ispublic: true, createdby: 'bhushan' } }
second request
body: {}
any inputs?
it looks more backend thing. should include code subscribes on http call.
by way, why using rc1? angular 2 on rc5.
Comments
Post a Comment