the common answer below isn’t working.
Whatever works don’t work in the apk .
I keep getting below errors with different configurations (loading file to loading using http)
- errors from CORS
- ERROR TypeError: Cannot read property ‘subscribe’ of undefined
- Could not read response
old answer
this.http.get(link).map(res => res.json()).subscribe((data) => {
console.log(data, "data");
},
err => {
console.log(err, "err");
})
loading from file
this.file.readAsText(this.url, endpoint).then((data) => {
this.core.log(data);
let myObservable = Observable.create(observer => {
observer.next(data);
});
}).catch(err => console.log(err));
return myObservable;
and the regular loading using http
observable = this.http.get("/android_asset/www/assets/mocks/file.json", reqOpts);
observable = this.http.get("/assets/mocks/file.json", reqOpts);
nothing works on device