import axios from "axios"
export function App() {
const config = {
headers: { Authorization: `Bearer TOKEN` },
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET",
'Access-Control-Allow-Headers': '*',
"Access-Control-Allow-Credentials": "true",
"Access-Control-Expose-Headers": "*",
"Accept": "application/json",
"Content-Type": "application/json",
"Origin": "*",
};
axios.get(
"https://URL",
config
)
.then(console.log)
.catch(console.log);
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"></script>
I've got problem with getting data from API using axios. It is blocked by CORS policy, I know that I use extension to website, but I am not allowed to use it. TOKEN and URL are hidden.
*Problem is only when I try to send request with axios, with http/curl it works. Also it's working while I am using CORS extension at Chrome
THAT SOLUTION WORKED FOR ME: