hi ,
when i try to tech data with axios , i have this error :
http://localhost:3000’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.
my code
const URL =‘https://kc.kobotoolbox.org/api/v1/data/formID.json’;
const [data, setData] = useState(null);
var myInit = { method: ‘GET’,
mode: 'no-cors',
cache: 'default' ,
headers : {
'Access-Control-Allow-Headers': 'Content-Type',
//'Access-Control-Allow-Headers': '*',
'Access-Control-Allow-Origin' : '*',
'Authorization':'Token *****************'
}
};
useEffect(() => {
axios.get(URL,myInit).then((response) => {
setData(response.data);
console.log(data)
});
}, []);