I have this function on the server side, forced to return true for the moment:
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
[HttpGet("cPasaAJefeVentas")]
public async Task<IActionResult> CPasaAJefeVentas(string idPais, string idCompania, string idSalesorg, string idDivision, string idUser, decimal porcentaje)
{
return Ok(true);
}
This is how you call it on the client side inside a service:
cPasaAJefeVentas(idPais: string , idCompania:string, idSalesOrg:string, idDivision:string, idUser:string, porcentaje:number) {
return this.http.get(this.altapedidosserveruri + 'cPasaAJefeVentas?=' + idPais + '&idCompania=' + idCompania + '&idSalesOrg=' + idSalesOrg + '&idDivision=' + idDivision + '&idUser=' + idUser + '&porcentaje=' + porcentaje);
}
And here is where i'm having issues right now:
cPasaJefeVentas(): boolean {
let descuentoDiscrecional: number = 5;
let res: boolean = null;
this.altaPedidosService
.cPasaAJefeVentas(this.pedidoObjeto.idPais, this.pedidoObjeto.idCompania,
this.pedidoObjeto.idSalesOrg, this.pedidoObjeto.idDivision, this.loggedService.logged.UserName, descuentoDiscrecional)
.subscribe((result: boolean) => (
console.log(result),
res = result
))
return res;
}
The console.log(result) prints TRUE, which is correct, but then i want to asignt that returned value to the "res" variable, and its not working, because it's still null when it exits the .susbscribe.
I want to know what am i doing wrong here? Why isnt the value of the "res" variable updating like it should?