-
-
Notifications
You must be signed in to change notification settings - Fork 27.2k
Closed
Description
I nearly create a project using create-react-app.
I set a proxy in package.json just like "proxy":"https://xx.com"
then I write a button on a page and do the fetch action, here is my code:
class App extends Component {
constructor(props) {
super(props);
this.fetch = this.fetch.bind(this);
}
fetch() {
fetch('/getPoplayer.json',{headers:{
"Accept":"text/html, application/xhtml+xml, application/json, */*"
}})
.then(function(response) {
return response.text()
}).then(function(json) {
console.log('parsed json', JSON.parse(json))
}).catch(function(ex) {
console.log('parsing failed', ex)
})
}
render() {
return (
<div className="App">
<Button onClick={this.fetch}>测试fetch</Button>
</div>
);
}
}
export default App;
after executing 'npm start' , the request is like this
the proxy not works , but I console.log the proxySetting in start.js , it is right.
PascalHelbig and devssh
Metadata
Metadata
Assignees
Labels
No labels
