Q:

Dynamically assigning var to json

I have a variable var locations in a .ts file and wish to have this equal to a json object in the same folder.  In other words the .json file changes every 5 seconds an I need the variable to update.  I assume that he rxjs observable is they way to go.  I have tried
ngOnInit() {
    timer(0, 7000).pipe(
      switchMap( _ => this.hawkerservice.fetchNews()
    )).pipe(
      map((ret:any) => {
       this.locations = ret 
      })
    ).subscribe();
  }

Now this works well except  .fetchNews() pull is over a port with:
export class MapjsonService{
  theUrl = 'http://localhost:8000/locations.json';
  constructor(private http: HttpClient) { }

  fetchNews(): Observable<any>{
    return this.http.get(this.theUrl)
  }

}

So my question is what is the best way to do this without passing the json object over a port.  Namely, just getting it locally.  
thx

A:

Well it is as simple as that. Your file is just another resource, which is hosted either locally or on server. You indeed need http to access it, because it is hosted.
Contradicting to your point, you can not simply run your application also without using http, even though it is hosted locally. Same is applicable for json file aswell.
You need http to access the file.

