I have one angular solution where service method calls api controller. but it is giving error. Code is given below :
user.service.ts
getMonthlyData(date: string): Observable<UserProfile> {
const url = `${this.api.baseUrl}auth/${date}`;
debugger;
return this.api.http.get<UserProfile>(url).pipe(
map((data) => {
debugger;
this.monthlyLeadsCount = data.monthlyLeadsCount ? data.monthlyLeadsCount : "";
this.monthlyOpportunitiesCount = data.monthlyOpportunitiesCount ? data.monthlyOpportunitiesCount : "";
this.monthlyAccountsCount = data.monthlyAccountsCount ? data.monthlyAccountsCount : "";
this.monthlyleads = data.monthlyLeadsList ? data.monthlyLeadsList : [];
//this.monthlyLeadsCountOfYear = data.monthlyLeadsCountOfYear ? data.monthlyLeadsCountOfYear : "";
this.loggedUser = data;
return this.loggedUser;
}),
retry(3), // retry a failed request up to 3 times
catchError(this.api.handleError) // then handle the error
);}
AuthController.cs
// GET api/auth/{date}
[AuthorizeSchema()]
[HttpGet("{date}")]
public ActionResult<UserProfileModel> GetMonthlyData(string date)
{
try
{
DateTime date1 = new();
var result = repo.GetMonthlyData(date1);
if (result == null)
{
return Unauthorized();
}
return Ok(result);
}
catch (Exception ex)
{
logger.LogError($"{nameof(Login)}: {ex.Message}");
}
return Unauthorized();
}
Here it is not getting call to api controller. Where is it going wrong?