【问题标题】:Get this type of response pending while fetching a API request在获取 API 请求时获取此类型的响应挂起
【发布时间】:2023-02-26 14:12:05
【问题描述】:
<script>
async function spam(){

  console.log("http://127.0.0.1:5000/hi");
 let response = await fetch("http://127.0.0.1:5000/500$");
  
  // alert();  
  console.log(response.json());


}
</script>

我如何获得正确的响应而不是挂起的请求,我的 json 数据是 {"spam"}

【问题讨论】:

    标签: javascript api


    【解决方案1】:

    在 response.json() 之前写 await 像这样 await response.json() 如果您的问题还没有解决,请在代码 sn-p 中给出完整的功能。

    【讨论】:

    • 这是完整的功能解决方案不起作用
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-09
    • 1970-01-01
    • 2017-11-08
    相关资源
    最近更新 更多