Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

Failed to get http.get angular 7.1.1

I have controller in c# which returns true or false wrapped with 'IHttpActionResult' and I'm using angular 7.1.1 on the client side. When I'm using httpclient.get, the server returns an answer, but the client doesn't receive anything. Also, I can't see the request on the Network tab in the DevTools, even though the server does receive the request. The c# server runs on different port from the client server. What is wrong? This is the controller function:

[HttpGet]
    public IHttpActionResult LogIn(string userName, string password)
    {
        bool status = RoboticsServiceServer.Instance.LogIn(userName, password);
        return Ok(status);
    }

This is the http.get function from the client side:

public logIn(username: any, password: any) {
this.$http.get(`http://localhost:50179/api/robotics/LogIn?username=${username}&password=${password}&key=Ik3k7u2K0ntcir3Yz3OZ6AaeRm1MU592`)
.toPromise().then(data => {     //I have tried 'subscribe' instead and the result is the same.
    if (data == true) {
      console.log("true");
    }
    else {
      console.log("false");
    }
  });

}

This is the app-routing.module.ts:

const routes: Routes = [];

@NgModule({
  imports: [RouterModule.forRoot(routes), HttpClientModule],
  exports: [RouterModule]
})

Comments