score:1

do you need to bind fetchApiToEntries in the constructor or use fat arrows?

this.fetchApiToEntries = this.fetchApiToEntries.bind(this);

sorry I cant comment not enough rep

score:2

Idk what your api response is but I tested your code with a fake API and changed

fetchApiToEntries(apiToFetch){}

to Arrow Function (Arrow Function)

fetchApiToEntries = (apiToFetch) => {}

and it's working fine.

Full Example:



    export default class Portfolio extends React.Component {
        constructor(props) {
            super(props);
            this.state = {
                entries: []
            }
        }
        componentDidMount() {
          this.fetchApiToEntries('https://jsonplaceholder.typicode.com/posts');
        }
        fetchApiToEntries = (apiToFetch) => {
            fetch(apiToFetch)
                .then(result => result.json())
                .then((entries) => {
                    this.setState({
                        ...this.state,
                        entries
                    })
                })
                .catch((error) => console.log(error));
        }
        render() {
          const {entries} = this.state;
            console.log(entries);
            return (
                // Everything you want to render.
            )
        }
    }

Hope it helps you.


Related Query

More Query from same tag