I can't figure this out!
(I've modified id codes for privacy...)
This works:
curl -vvv -H "Authorization: Bearer 3t8D7CeQ3MDPADCI" -X "DELETE" https://www.blockonomics.co/api/button?uid=8778e542911eb-ff979c
But in my Reactjs module, this does not work:
// urlDelete = 'https://www.blockonomics.co/api/button?uid='
// item = '8778e542911eb-ff979c'
const handleDelete = async (item) => {
const url = urlDelete + item
await axios
.delete(url, {
headers: {
Authorization: 'Bearer 3t8D7CeQ3MDPADCI',
},
})
.then((res) => {
console.log(res.status)
})
}
Errors:
- Unhandled Rejection (Error): Network Error
- 405 Method Not Allowed
- CORS Missing Allow Origin
- Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://www.blockonomics.co/api/button?uid=8778e542911eb-27ffea. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).
- Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://www.blockonomics.co/api/button?uid=8778e542911eb-27ffea. (Reason: CORS request did not succeed).
I've tried adding a cors-anywhere proxy to the url with no success. I've tried using 'GET' and 'POST', still nothing.
Why does the curl command work but the axios function doesn't?
I'd really appreciate some advice about this. I'm stuck!