question for you, why not have this data in a backend like a database, mongodb etc? then let us say another instance of your same website or yet another totally different website needs to read the data, wouldnt it be better to have this reside on a database that can be accessed by both websites via a service?
On Friday, January 11, 2019 at 10:37:42 AM UTC-8, Bakadiri Abdelouahab wrote: > > So I must put my file in a asset folder. It’s work now thank you so much. > > Le ven. 11 jan. 2019 à 02:38, Tito <[email protected] <javascript:>> a > écrit : > >> I saw this on SO >> >> import { HttpClient } from '@angular/common/http'; import { Observable } >> from 'rxjs/Observable'; >> >> constructor(private http: HttpClient) { >> this.getJSON().subscribe(data => { >> console.log(data) >> }); >> } >> >> public getJSON(): Observable<any> { >> return this.http.get("./assets/mydata.json") >> } >> >> >> On Thursday, January 10, 2019 at 10:50:14 AM UTC-8, Bakadiri Abdelouahab >> wrote: >>> >>> Hello; >>> I have a local JSON file that conient a list of products, I want to >>> access to it using a HTTP service through a get function, my class service >>> and the json file are in the same folder, when i put: >>> getProducts(): Observable<Iproduct[]> { >>> return this._http.get<Iproduct[]>('./products.json'); >>> } >>> I have a error like this: >>> GET http://localhost:4200/products.json 404 (Not Found) >>> Do you have any idea about where angular put this file while it build my >>> application. >>> thank you. >>> >> -- >> You received this message because you are subscribed to the Google Groups >> "Angular and AngularJS discussion" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected] <javascript:>. >> To post to this group, send email to [email protected] >> <javascript:>. >> Visit this group at https://groups.google.com/group/angular. >> For more options, visit https://groups.google.com/d/optout. >> > -- > Envoyer depuis mon Iphone > -- You received this message because you are subscribed to the Google Groups "Angular and AngularJS discussion" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.
