TypeScript 始终使用 GET 而不是 POST,而方法是:'POST'被执行
我正在尝试使用 TypeScript 和我的 Swagger 本地主机服务器进行密码身份验证。但我的问题是,它总是使用 GET 而不是 POST...
function checkPassword() {
const inputUsername = <HTMLInputElement>document.getElementById('username-field');
let username = inputUsername.value;
const inputPassword = <HTMLInputElement>document.getElementById('password-field');
let password = inputPassword.value;
const requestObject = {
userName: username,
password: password,
}
fetch("http://localhost:5000/login",{
method: 'POST',
redirect: 'follow',
body: JSON.stringify(requestObject)
})
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
}
I am trying to make a password authentikation using TypeScript and my Swagger localhost server. But my problem is, that it is always using GET instead of POST...
Image of my FireFox Network settings
function checkPassword() {
const inputUsername = <HTMLInputElement>document.getElementById('username-field');
let username = inputUsername.value;
const inputPassword = <HTMLInputElement>document.getElementById('password-field');
let password = inputPassword.value;
const requestObject = {
userName: username,
password: password,
}
fetch("http://localhost:5000/login",{
method: 'POST',
redirect: 'follow',
body: JSON.stringify(requestObject)
})
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论