title: Ionic POST: native HTTP returns ERROR null
body: <p><br/>
  <br/>
  I'm trying to get a simple app to work on iOS with Ionic.
  <br/>
  <br/>
  The app contains a simple button to do a POST request to my servlet located on my server with the function <strong>login(username, password)</strong>.
  <br/>
  <br/>
  At first I thought it was a server-side problem so I tried doing a POST via POSTMAN software.
  <br/>
  The result was perfect and the response was a JSON.
  <br/>
  But when I try to do it on my iPhone, the native http component throws an error where all values are null.
  <br/>
  <br/>
  So I'm thinking it has something to do with my typescript code, can you help me out?
  <br/>
  <br/>
  <strong>My typescript code:</strong></p>
  
  <pre><code>    import { Component } from '@angular/core';
      import { IonicPage, NavController, NavParams } from 'ionic-angular';
      import { TabsPage } from '../tabs/tabs';
      import { HTTP } from '@ionic-native/http';
      import 'rxjs/add/operator/map';
      import { Storage} from '@ionic/storage';
      import { ShareService } from '../../services/share/share';
  
  
  
      @IonicPage()
      @Component({
        selector: 'page-login',
        templateUrl: 'login.html',
      })
      export class LoginPage {
  
        static readonly SERVER_ADDRESS  = 'http://example.com';
  
        constructor(public navCtrl: NavController, public navParams: NavParams, private http: HTTP, private storage:Storage, private shareService: ShareService) {
          this.storage.ready().then( () =&gt; {
            this.storage.get("user").then( (user) =&gt; {
              if( user !== null){
                console.log(shareService.getUserName());
                shareService.setUser(user.firstName,user.lastName,user.username,user.customer);
                this.navCtrl.push(TabsPage);        
              }
            });
          });
        }
  
        ionViewDidLoad() {
          console.log('ionViewDidLoad LoginPage');
        }
  
        login(username,password){
  
          var body = {
            username: username.value,
            password: password.value
          }
          let header:any = {
            'Content-Type': 'application/json'
          }
  
  this.http.setDataSerializer('json');   
  this.http.post(LoginPage.SERVER_ADDRESS+'/external/MobileLoginServlet',body,header).then(
            data =&gt; {
              var response = JSON.parse(data.data);
              let user = response[0];
              user.customer = 3;
              user.firstname = "Christian";
              user.lastName = "Prellwitz";
              console.log(user);
              this.storage.ready().then( () =&gt;{
                 this.storage.set("user",user); 
              });
              this.navCtrl.push(TabsPage);    
            }).catch(error =&gt;{
              console.log(error);
              console.log(error.status);
              console.log(error.error);
              console.log(error.headers);
            });
  
        }
  
      }
  </code></pre>
  
  <p><strong>My Servlet CORS:</strong></p>
  
  <pre><code>response.setHeader("Access-Control-Allow-Origin", "*");
  response.setContentType("application/json");
  response.setCharacterEncoding("UTF-8");
  </code></pre>
  
  <p><strong>What the http component returns:</strong></p>
  
  <pre><code>[app-scripts] [11:19:53]  console.log: [object Object]
  [app-scripts] [11:19:53]  console.log: null
  [app-scripts] [11:19:53]  console.log: null
  [app-scripts] [11:19:53]  console.log: null
  </code></pre>
  
  <p><br/>
  Thanks for your help in advance.</p>