fetch api example get web content
Example 1: fetch api map
const GetData = [];
useEffect(() => {
fetch(API_URL)
.then((res) => res.json())
.then((data) => {
GetModesData.push(...data);
setDataState(GetData.map((d) => d.modeName));
});
}, []);
Example 2: fetch
fetch('http://example.com/movies.json')
.then(response => response.json())
.then(data => console.log(data));