I'm using an api for fantasy football data, specifically in this example from the following URL: https://fantasy.premierleague.com/api/entry/1225457/
When I try to send a GET request using axios in javascript (React) like so:
export function AgentCard(){
const [agentInfo,setAgentInfo] = useState({});
useEffect(()=> {
console.log('running useEffect')
axios.get('https://fantasy.premierleague.com/api/entry/1225457/').then(res=>{
console.log(res);
})
},[])
return(
<div>
<h1>Test</h1>
</div>
)
}
I get the following error in the browser console:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://fantasy.premierleague.com/api/entry/1225457/. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). Status code: 200
But when I try to access the endpoint from a browser (Mozilla), it displays the contents
I know there's something up with the API because my code works for other APIs