以下是控制器的一部分:
[HttpPost]
[AllowAnonymous]
public async Task<IActionResult> Get([FromBody] LoginViewModel model)
{
MembershipContext _userContext = _tokenService.ValidateUser(model.Email, model.Password);
if (_userContext.Principal == null)
{
logger.LogInformation($"Invalid username ({model.Email}) or password ({model.Password})");
return BadRequest("Invalid credentials"); // Here..
}...
错误请求的返回中包含“无效凭据”。。
在浏览器上,从哪里获取响应.状态由于“400”和“坏请求”都很好,但是我找不到可以检查“无效凭据”的位置-找不到它的位置。
这是我的回执。。。
// Lets do a fetch!
const task = fetch("/api/jwt", {
method: "POST",
body: JSON.stringify(this.userLogin),
headers: new Headers({ 'content-type': 'application/json' })
})
.then(response => {
console.log("STATUS: ", response.status, response.statusText)
return response.json()})
.then(data => {
console.log("got here", data)
localStorage.setItem(this.TOKEN_KEY, JSON.stringify(data));
})
.then(() => {... so on..