我已经做了一个API,应该得到一个用户通过他们的电子邮件,但我得到一个错误。我有类似的API,只是工作,我认为它出错了,当我发送到控制器。
错误:
Resolved [org.springframework.web.bind.MissingServletRequestParameterException: Required request parameter 'email' for method parameter type String is not present]
验证码:
<div class="settingBlock">
Invite player by email <br>
<input v-model="invitedPlayer" id="invitedPlayer" type="text" class="field" required placeholder="Email" />
</div>
data() {
return {
invitedPlayer: ""
}
},
computed: {
email() {
return this.invitedPlayer;
}
},
const authService = new AuthService();
authService.getUserByEmail(this.email)
授权服务
getUserByEmail(email) {
return api.get("/auth/get", {
email
})
}
主计长
@GetMapping("/get")
public ResponseEntity<Optional<User>> getUserByEmail(@RequestParam String email) {
Optional<User> user = userRepository.findByEmail(email);
if (user == null) {
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
return new ResponseEntity<>(user, HttpStatus.OK);
}
用户存储库
public interface UserRepository extends JpaRepository<User, Long> {
Optional<User> findByUsername(String username);
Optional<User> findByEmail(String email);
1条答案
按热度按时间bjp0bcyl1#
不确定
api
在Vue上下文中是什么,但我猜您需要将Authservice更改为