why fetch from react to flask back end not working
//There are some packages you can use like fetch-with-proxy or node-https-proxy-agent, fetch-with-proxy can get HTTP_PROXY env var to set proxy, and you can use the other create proxy agent.
//But I recommend that to use other package to send request like axios.
import axios from 'axios';
const axios_ = axios.create({
baseURL: 'http://localhost:5000',
headers: { 'Content-Type': 'application/json' },
})
class App extends React.Component {
componentDidMount() {
axios_.get('/')
.then(response => {
console.log(response.text()) //Here is the text() i said before
this.setState({ snippets: response.data })
})
.catch(error => {
console.log(error)
});
}
...}