Angular HTTP Client

Hey, i am currently developing an App for my graduation at a higher technical collage.

My problem is that, my app does not get any data on mobile devices. Is it possible that the HTTPClient from Angular does not work on mobile devices? Please be not distracted by the localhost, i use a VPN to be in the network where the backend runs.

Could you please tell me what i have to use or whats the problem? I could not find any satisfying solutions online.

Here is my ApiDataService:

import { HttpClient } from ‘@angular/common/http’;

@Injectable({
providedIn: ‘root’
})
export class APIDataService {

private api = ‘http://localhost:11218/lehrer’;
private id = ‘SCRE’;

private gruppen: Gruppe;
private schueler: Schueler;

constructor(
private http: HttpClient,
private storage: Storage
) { }

getGruppen(): Observable<Gruppe> {
return this.http.get<Gruppe>(${this.api}/gruppen/${this.id});
}

getSchuelerFromGruppe(grpId: number): Observable<Schueler> {
return this.http.get<Schueler>(${this.api}/schueler/gruppen/${grpId});
}

Do you get any error or are you getting null data?

Does changing http to https make any difference?

1 Like

I dont geht any error or something. When executing the app in a simulated device in xcode everything works perfect, but only on a real device the data isnt visible. I am really confused. Does this mean that the problem is at my code (HTTPClient), or is it just a problem with the network?

I am sorry for writing such abstract stuff.

Your code is perfectly fine. I’m just not sure whether to pin the cause of your problem on your network.

1 Like

Try to use a different http endpoint in the outside world from one of the many tutorials (spotify, google, esrthquake data weather etc)

Just a dummy http request to isolate what is working and isnt

1 Like

When using an different api, the data can be loaded. It seems that the problem is on server side and not in my program. Thank you!