I creates an application by using angular 7 and asp.net core when i when create the login page, i get this errorr: error: SyntaxError: Unexpected token L in JSON at position 0 at JSON.parse () at XMLHtt
login.service
UserLogin(logModel: LoginModel): Observable<LoginModel> {
return this.http.post<LoginModel>(this.url + 'Login', logModel, this.headers).pipe();
}
and this is my component, login.ts
login(){
if(this.loginForm.valid){
this.VaildateModel();
this.LoginService.UserLogin(this.logModel).subscribe(success =>{
this.route.navigate(['home']);
}, err => {
console.log(err);
this.message = err.error;
}
)
}
}
and this my function in web api app
[HttpPost]
[Route("Login")]
public async Task<IActionResult> Login(LoginModel model)
{
if (model == null)
return NotFound();
var user = await _manager.FindByEmailAsync(model.Email);
if (user == null)
return NotFound();
//if (!user.EmailConfirmed)
// return Unauthorized("Email is not Confirmed yet");
var result = await _signInManager.PasswordSignInAsync(user, model.Password, model.RememberMe, true);
if (result.Succeeded)
{
return Ok("Login Success");
}
else if (result.IsLockedOut)
{
return Unauthorized("User Account is locked");
}
return StatusCode(StatusCodes.Status204NoContent);
}
can anyone help me please :( ?