Send and receive a data in post method


#1

Thank you so much @nwercto .and I need one more help … I want to send and receive a data in post method. I followed one tutorial. But i got an error
Error

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://0.0.0.0:2800/login. (Reason: CORS header 'Access-Control-Allow-Origin' missing).

code:

ionViewidData(){   
 let headers= new Headers();    
headers.append('Content-Type','application/json');
    let body = {            id:"10077",      password:"leechan2"    };   
 console.log(body);    
this.http.post('http://0.0.0.0:2800/login',JSON.stringify(body),{headers:headers})        
.map(res => res.json())        
.subscribe(data =>{         
 console.log(data);       
 },        (err)=>{          
console.log("failed")       
 });
}

Uncaught (in promise): Error: No provider for Http
#2

Try to put this (all the code) in the Constructor, not the ionViewData event


#3

Look on your error message "Access-Control-Allow-Origin"
You need to allow cross origin in your server