如何发送HTTP REQUEST到Spring Cloud API GATEWAY

问题描述 投票:0回答:0

当我在项目中手动向 URL 发出网关请求时,它会为我提供正确的数据,但是当我尝试使用前端发送 http 请求时,API 不起作用。这是为什么?

JavaScript

<script>
  document.getElementById("signupbtn").addEventListener("click",function(){
    const username = document.getElementById("username").value;
    const password = document.getElementById("password").value;

 
    const xhr = new XMLHttpRequest();
    xhr.open("POST","http://localhost:9000/user/register?username=${username}&password=${password}");
    xhr.send();
  })

</script>

我的问题是如何使用按钮从前端向 api 网关发送 http 请求

javascript java html microservices api-gateway
© www.soinside.com 2019 - 2024. All rights reserved.