[英]Fetch cURL request using React
I have a GET curl request我有一个 GET curl 请求
curl -X GET "http://localhost:8000/get/folder" -H "accept: application/json" -H "path: /"
Something like this should work.像这样的东西应该工作。
fetch('http://localhost:8090/get/directory', {
headers: {
'Accept': 'application/json',
'Path': '/',
}
})
.then(response => response.json())
.then(json => console.log(json));
You can call this from in a useEffect()
in your React app, for example.例如,您可以在 React 应用程序的useEffect()
中调用它。 Or componentDidMount
if it is a class component.如果是 class componentDidMount
,则为 componentDidMount。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.