I'm trying to communicate with an api with react. I was getting a cors error so i created a proxy api. I'm still getting a 403 error but this time it's different. I get a captcha error. I get data when i open the url in browser and also when i make a request in postman, but not through node js
const express = require('express');
const cors = require("cors");
const axios = require('axios');
const app = express();
const port = process.env.PORT || 8000;
app.use(cors({
origin: '*'
}));
app.get("/", (req, res) => {
const url = `URL_TO_EXTERNAL_API`;
axios.get(url)
.catch(error => console.log(error))
.then(resp => {
console.log(resp);
});
});
app.listen(port, () => console.log(`http://localhost:${port}`));
here's a portion of the error i get
Here's the react request ->
fetch(local, {
method: 'get',
headers: new Headers({
'Content-Type': 'application/json'
})
}).then(response => {
return response.json();;
}).then(data => {
this.setState({ announcements: data })
});
where local is "http://localhost:8000?params..."
Do you know why the current solution is not working ?