When I post data from my native script angular app which will be running on my android device to my local API which is using dotnet core API. I get an error Error: java.net.ConnectException: failed to connect to localhost/127.0.0.1 (port 59521): connect failed: ECONNREFUSED. I can hit my API using postman.
I change from using the Httpclient module to HTTP common, with no luck and I have added android:usesCleartextTraffic="true" to the android manifest.
login(user: User) {
return this.http.post(
BackendService.baseUrl + "user/login",
JSON.stringify({
username: user.email,
password: user.password
}),
{ headers: this.getCommonHeaders() }
)
.pipe(
tap((data: any) => {
BackendService.token = data._kmd.authtoken;
}),
catchError(this.handleErrors)
);
}
I expect to get an success but I get Error: java.net.ConnectException: failed to connect to localhost/127.0.0.1 (port 59521): connect failed: ECONNREFUSED.