Can RxJs fetch data from local json file?

284 Views Asked by At

I am trying to fetch json data from a local json file using 'ajax' operator of RxJs but I am getting null as a response.

const url='../assets/json/response.json';

ajax.getJSON(url).subscribe({
 next: res => { console.log(res); },
 error: err => { console.log(err);}
});

It is printing null from the next block, which means it is able to find the json but it is not returning it's contents. I tried 'fromFetch' also but still the same, null response.

I am trying it in a react environment.

0

There are 0 best solutions below