frustrated-dev
frustrated-dev

Reputation: 451

TypeError: Object doesn't support property or method 'json'

i'm having trouble with this .json, it keeps saying "Object doesn't support property or method 'json'". Do i have to add another imports for this one? guide me guys thanks for your future answers.

import { HttpClientModule, HttpClient } from '@angular/common/http';
import { map } from 'rxjs/operators';
import { Response } from "@angular/http";
import { Injectable } from '@angular/core';

/*
  Generated class for the DataServiceProvider provider.

  See https://angular.io/guide/dependency-injection for more info on 
providers
  and Angular DI.
*/

@Injectable()
export class DataServiceProvider {

  constructor(private http: HttpClient) {
    console.log('Hello DataServiceProvider Provider');
  }
      getMenus(){
      return this.http.get('assets/data/menus.json')
       .pipe(map((response:Response)=>response.json()));
    }
}

Upvotes: 1

Views: 468

Answers (1)

Sajeetharan
Sajeetharan

Reputation: 222710

You do not need to have .json.No longer need to call this function yourself.

 return this.http.get('assets/data/menus.json')
       .pipe(map((response:Response)=>response));

Upvotes: 2

Related Questions