Please tell me there is the following code:
import React, { Component } from 'react'; import styles from './table.css'; class App extends Component { constructor(props) { super(props); this.state = { VacTitle: '11' }; }; getApi(id){ fetch('https://api.hh.ru/vacancies/'+id) .then(function(response) { return response.json(); }) .then(function(data) { console.log('Request successful', data); return data; }) .catch(function(error) { console.log('Request failed', error) }); } render() { return ( <div> <img src="true" onError={this.getApi(this.props.id)} /> </div> ); } } export default App; How to display data received via getAPI in state? It does not work(
PS I did this (onError), since src is not, the function will work like window.onLoad :)