1

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()));
    }
}

1 Answer 1

2

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));
Sign up to request clarification or add additional context in comments.

1 Comment

wow your so fast like 1 sec. after my post? Are you an AI?? thanks man

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.