I am able to run my ionic app on my laptop by using the ionic lab command.
The app makes calls to the IMDB api, & displays data retrieved from it.
Now, I am trying to run the app on an android device.
by using the following command: ionic cordova run android --device.
The app appears on my phone, but when I search for IMDB data, no results are appearing.
Below is the service I am using to make calls to the API:
export class MovieService {
url = 'http://www.omdbapi.com/';
apiKey = 'myKey';
constructor(private http: HttpClient) { }
searchData(title: string, type: SearchType): Observable<any> {
return this.http.get(`${this.url}?s=${encodeURI(title)}&type=${type}&apikey=${this.apiKey}`)
.pipe(
map(results => {
console.log('RAW', results);
return results['Search'];
})
);
}
getDetails(id): Observable<any> {
return this.http.get(`${this.url}?i=${id}&plot=full&apikey=${this.apiKey}`);
}
}
Can someone please tell me why the app is working on my laptop, but when I try to use it on my phone it isn't working as expected?
Probably one reason is that you are using http not https.
Android restricted access to non-secure feeds in a recent security update.
Try:
url = 'https://www.omdbapi.com/';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With