Как офетчить данные для React компонента

Jun 28, 2018 10:49


componentDidMount(){
this.setState({ isLoading: true });
console.log('---', 'Fetch RUN');
return fetch('./GetZakupki', {
      method: 'GET',
      headers: {
      "Accept": "application/json",
      'Content-Type': 'application/json'
      }
  })
  .then(response => { return response.json();})
  .then(responseData => this.setState({ articlesFromServer: responseData, isLoading: false }))
  .then(data => {this.setState({"questions" : data});})
  .catch(err => {
      console.log("Attention fetch error: " + err);
  });}

json, react

Previous post Next post
Up