Answers for "angular load json file with httpclient"

0

angular load json file with httpclient

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

@Injectable()
export class AppSettingsService {

   constructor(private http: HttpClient) {
        this.getJSON().subscribe(data => {
            console.log(data);
        });
    }

    public getJSON(): Observable<any> {
        return this.http.get("./assets/mydata.json");
    }
}
Posted by: Guest on February-23-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language