# Ionic 3 HTTP request not working on ios ,but works on android?

**URL:** <https://forum.ionicframework.com/t/ionic-3-http-request-not-working-on-ios-but-works-on-android/129680>\
**Category:** ionic-v3\
**Created:** [May 4, 2018, 11:59am UTC](https://forum.ionicframework.com/t/ionic-3-http-request-not-working-on-ios-but-works-on-android/129680 "2018-05-04T11:59:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![lohith95](https://avatars.discourse-cdn.com/v4/letter/l/7ab992/32.png) [@lohith95](https://forum.ionicframework.com/u/lohith95)\
**Post date:** [May 4, 2018, 11:59am UTC](https://forum.ionicframework.com/t/ionic-3-http-request-not-working-on-ios-but-works-on-android/129680/1 "2018-05-04T11:59:50Z")

</div>

I have an Ionic 3 application that calls a Spring Boot API to login into Mobile App,My Spring Boot application is hosted in Aws. It works on android But it doesn’t work on ios ,It Says Cross Issue I tried Many Solutions form internet But did not get the result.

The error I am getting is

> response with status: 0 for url : null

this is my ionic provider/service

```auto
import { Http, Response} from '@angular/http';
import { Injectable } from '@angular/core';

@Injectable()
export class loginService {

 data:any;

    constructor(public http : Http){}

    getAllUsers(authData){
        alert("api users")

        return new Promise(resolve=>{
            this.http.post('http://someAddress:8080/api/customerr/getUser', authData)
            .map(res=>res.json())
            .subscribe(data=>{
                this.data=data;
                resolve(this.data)
            })
        })

    }

}

```

This is the login page where I am calling the api

```auto
import { Component, ViewChild } from '@angular/core';
import { Alert,AlertController,IonicPage,Loading,LoadingController,NavController,MenuController } from 'ionic-angular';
import { FormBuilder, FormGroup, Validators, NgForm } from '@angular/forms';
import { EmailValidator } from '../../validators/email';
import { CustomerPage } from '../customer/customer';
import { loginService } from '../../providers/loginservice/login.servie';
import {Response} from '@angular/http';
import { ToastController } from 'ionic-angular';
import { CustomerdetailsPage } from '../customerdetails/customerdetails';
@IonicPage()
@Component({
  selector: 'page-login',
  templateUrl: 'login.html',
})
export class LoginPage { 

  @ViewChild('f') loginForm: NgForm;

  loginResponse:any;
  constructor(
    public navCtrl: NavController,
    public loadingCtrl: LoadingController,
    public alertCtrl: AlertController,
    public menu:MenuController,
    private loginservice : loginService,
    private toastCtrl: ToastController

  ){

    }

  ionViewWillEnter(){
    this.menu.enable(false)
  }

  ionViewWillLeave(){
    this.menu.enable(true)
  }

     loginUser() {
      console.log("login data");
       console.log(this.loginForm.value);

       this.loginservice.getAllUsers(this.loginForm.value).then(

            (data:any) => 
            {
              this.loginResponse = data.json();
              alert("data");
              alert(this.loginResponse.code);
              if(this.loginResponse.code === '200')
              {
                        if(this.loginResponse.data.length !== 0)
                        {

                           let key1 = 'islogIn';
                           localStorage.setItem(key1, "true");

                          this.navCtrl.setRoot(CustomerPage);                       
                        }
                         else if(this.loginResponse.data.length == 0)
                        {

                            let toast = this.toastCtrl.create({
                              message: 'invalid username or password',
                              duration: 3000,
                              position: 'bottom'
                            });

                            toast.onDidDismiss(() => {
                              console.log('Dismissed toast');
                            });

                            toast.present();

                        }

              }
             else if (this.loginResponse.code === '300')
                        {

                          let toast = this.toastCtrl.create({
                            message: 'user is deactivated',
                            duration: 3000,
                            position: 'bottom'
                          });

                          toast.onDidDismiss(() => {
                            console.log('Dismissed toast');
                          });

                          toast.present();

                        }
            },
            (error)=>{
              alert(error);
            }

          );

    }

}

```

And this the app.module.ts

```auto
@NgModule({
  declarations: [
    ..
    LoginPage,
  ...

  ],
  imports: [
    BrowserModule,
    HttpClientModule,
    HttpModule,
    IonicStorageModule.forRoot(),
    IonicModule.forRoot(MyApp),
  ],
  bootstrap: [IonicApp],
  entryComponents: [
    .
    .
    LoginPage,
    .
    .
  ],
  providers: [
    Network,
    StatusBar,
    SplashScreen,
    {provide: ErrorHandler, useClass: IonicErrorHandler},
    Storage,
    SocialSharing,
    File,
    FileOpener,
    DatabaseProvider,
    SQLitePorter,
    SQLite,
    GlobalProvider,
    PageserviceProvider,
    loginService,
    syncService

   ]
})
export class AppModule {}

```

---

<div class="post-metadata">

**Author:** ![zubinraja](https://avatars.discourse-cdn.com/v4/letter/z/3bc359/32.png) [@zubinraja](https://forum.ionicframework.com/u/zubinraja)\
**Post date:** [October 14, 2018, 1:04pm UTC](https://forum.ionicframework.com/t/ionic-3-http-request-not-working-on-ios-but-works-on-android/129680/2 "2018-10-14T13:04:04Z")

</div>

Facing same issue. Did you found the solution?

---

<div class="post-metadata">

**Author:** ![dmlkl](https://avatars.discourse-cdn.com/v4/letter/d/bc79bd/32.png) [@dmlkl](https://forum.ionicframework.com/u/dmlkl)\
**Post date:** [February 18, 2019, 12:21am UTC](https://forum.ionicframework.com/t/ionic-3-http-request-not-working-on-ios-but-works-on-android/129680/3 "2019-02-18T00:21:29Z")

</div>

Hello,

Have you found the solution? Or any alternative way?

Thanks.

---

<div class="post-metadata">

**Author:** ![mhartington](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mhartington/32/137757_2.png) [@mhartington](https://forum.ionicframework.com/u/mhartington)\
**Post date:** [July 19, 2021, 9:37pm UTC](https://forum.ionicframework.com/t/ionic-3-http-request-not-working-on-ios-but-works-on-android/129680/4 "2021-07-19T21:37:10Z")

</div>

Closed on July 19, 2021, 9:37pm UTC


