Can't fetch data using react from django rest framework generated api
http://127.0.0.1:8000/api/additionalskills/?format=json This link provides me an API at my localhost. The API is generated by Django Rest Framework. Now I wish to use the API data in my ReacJS application. To do that I followed the way below:
const [additionalSkills, setAdditionalSkills]= useState([]);
useEffect(() =>{
fetch('http://127.0.0.1:8000/api/additionalskills/?format=json')
.then(res=>res.json())
.then(data=> {
setAddSkills(data)
})
},[])
The API is getting generated well but when I try to fetch data using the API from my React app, the React app gets collapsed. Help me to slove it.