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