Getting an error whenever I declare my function inside the Jswrapper at my React class

I’m getting an error whenever I declare my getDataFromApi function inside my class AppWrapper
imageShowingError

The problem is that I thought just by putting them inside curly braces, the problem would be resolved, but I was wrong, can someone help me?