【问题标题】:Fetch cURL request using React使用 React 获取 cURL 请求
【发布时间】:2021-03-17 07:49:02
【问题描述】:

我有一个 GET curl 请求

curl -X GET "http://localhost:8000/get/folder" -H  "accept: application/json" -H  "path: /"

【问题讨论】:

    标签: javascript html reactjs curl


    【解决方案1】:

    这样的事情应该可以工作。

    fetch('http://localhost:8090/get/directory', { 
      headers: {
        'Accept': 'application/json',
        'Path': '/',
      }
    })
    .then(response => response.json())
    .then(json => console.log(json));
    

    例如,您可以在 React 应用程序的 useEffect() 中调用它。或者componentDidMount,如果它是一个类组件。

    【讨论】:

      猜你喜欢
      • 2021-05-05
      • 2020-09-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-14
      • 1970-01-01
      • 2014-12-09
      • 2017-03-29
      相关资源
      最近更新 更多