Ionic 3 Login Authentication Using API - Cannot read property 'json' of null

后端 未结 4 1259
情深已故
情深已故 2021-01-17 18:14

I am doing authentication in Ionic 3 using API but In the login process, it is showing error: Cannot read property \'json\' of null

This is my provi

4条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-17 18:29

    The problem is in your restapi.ts constructor, HttpClient causing the issue;

      constructor(public http: HttpClient) {
        console.log('Hello RestapiProvider Provider');
      }
    

    Change that to this,

      constructor(public http: Http) {
        // console.log('Hello RestapiProvider Provider');
      }
    

    You have an error on this part {headers: headers} here is your error :

    Argument of type '{ headers: Headers; }' is not assignable to parameter of type '{ headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: "body"; params?: Ht...'. Types of property 'headers' are incompatible. Type 'Headers' is not assignable to type 'HttpHeaders | { [header: string]: string | string[]; }'. Type 'Headers' is not assignable to type '{ [header: string]: string | string[]; }'. Index signature is missing in type 'Headers'.

    Error is pretty clean so does not need any explanation, your code will work without any issue if you do that change. I tested on my local.

提交回复
热议问题