0

When I try to add api connection part in the ionic provider from Angular web app service it shows Expected 0 arguments but got 1 in here:

@Injectable({
  providedIn: 'root'
})

While the same is working in the Angular web project.

Ionic3 provider looks like this:

import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Observable';

const BASEURL = 'http://domain...';

@Injectable({
  providedIn: 'root'
})
export class AuthProvider {
  constructor(private http: HttpClient) { }

  RegisterUser(body): Observable<any> {
    return this.http.post(`${BASEURL}/register`, body);
  }

  LoginUser(body): Observable<any> {
    return this.http.post(`${BASEURL}/login`, body);
  }
}

How to fix this?

NewTech Lover
  • 1,185
  • 4
  • 20
  • 44

1 Answers1

1

change this :

(new in angular 6 wont work in ionic 3)

@Injectable({
 providedIn: 'root'
})

to this

@Injectable()

or upgrade to ionic 4

AbdulAzeem
  • 529
  • 4
  • 8
  • Will it work without provided In: 'root'? Because in Angular it was used. – NewTech Lover May 28 '19 at 09:49
  • @NewTechLover take a look at this https://stackoverflow.com/questions/50307628/angular-injectable-decorator-expected-0-arguments-but-got-1 – AbdulAzeem May 28 '19 at 10:03
  • @NewTechLover ionic 3 does not officially support angular 6 https://forum.ionicframework.com/t/upgrading-to-angular-6/131121/5 – AbdulAzeem May 28 '19 at 10:05