Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

299
Visualizações
Ionic 2 Project - Promise issue with authentication

I've been searching for a solution to this problem I'm having, but haven't found anything that works for my particular case. I am working on an Ionic 2 application and I am working on some authentication stuff for my login screen. The purpose of this file is to add backend functionality to the front end code I wrote (refer to my login.html file on the github link below). I was following the tutorial on this website: https://devdactic.com/login-ionic-2/

The problem I am having is that for certain functions, which will be marked in my code, I am getting a "Promise returned from (function) is ignored" which stops the code from functioning entirely. It doesn't come up as a compile error, but instead it is a runtime error that is:

Runtime Error Uncaught (in promise): Error: No provider for Http! Error at d

I am really not sure what this means, so any insight would be very helpful. If needed, I can provide a picture of the full error.

@IonicPage()
@Component({
  selector: 'page-login',
  templateUrl: 'login.html',
})
export class LoginPage {
  loading: Loading;
  registerCredentials = { email: '', password: ''};

  constructor(public navCtrl: NavController, private auth: AuthService, public navParams: NavParams,
  private alertCtrl: AlertController, private loadingCtrl: LoadingController) {}

  public createAccount() {
    this.navCtrl.push('RegisterPage'); //Promise ignored error
  }

  public login() {
    this.showLoading();
    this.auth.login(this.registerCredentials).subscribe(allowed => {
        if (allowed) {
          this.navCtrl.setRoot('HomePage'); //Promise ignored error
        } else {
          this.showError("Access Denied");
        }
      },
      error => {
        this.showError(error);
      });
  }

  showLoading() {
    this.loading = this.loadingCtrl.create({
      content: 'Please wait...',
      dismissOnPageChange: true
    });
    this.loading.present(); //Promise ignored error
  }

  showError(text) {
    this.loading.dismiss(); //Promise ignored error

    let alert = this.alertCtrl.create({
      title: 'Fail',
      subTitle: text,
      buttons: ['OK']
    });
    alert.present(prompt); //Promise ignored error
  }
}

Picture of the error: enter image description here

I am just not sure what is causing this problem, and it is causing my code to crash entirely and won't even load my UI. If you need to look at some of the other files, the rest is on my github, this particular file is located in /src/pages/login.

The rest of the files: https://github.com/jparr721/Badmeat/tree/master/BadMeat-Ionic/FirstBuild/src

  • IDE: JetBrains WebStorm
  • OS: MacOS Sierra
  • Ionic Version: 2.2.2
over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

You probably figured it out already but try changing the public to private in your code over here:

constructor(public navCtrl: NavController,

try:

constructor(private navCtrl: NavController,
over 4 years ago · Santiago Trujillo Relatório

0

I'm not sure if this will fix your problem but try adding the following to your app.module.ts file

import { HttpModule } from '@angular/http';

it may fix your http provider error you will also have to add it to imports in the same file

imports: [
    BrowserModule,
    HttpModule,
    CloudModule.forRoot(cloudSettings),
    IonicModule.forRoot(MyApp),
    IonicStorageModule.forRoot()
  ],
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda