I'm making web using react.
Most of my react code is from airbnb style ( https://github.com/airbnb/react-dates )
but I can't find How to use Fetch API in react web.
can you recommend a good example?
You can look at this article https://daveceddia.com/ajax-requests-in-react/
It uses axios
but you can follow the same pattern and replace the axios
code with
fetch('http://api.exampledomain.com/api/search')
.then((response) => response.json())
.then((jsonData) => {
//handle json data processing here
console.log(jsonData);
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.