I am creating react application to fetch data from youtube API and for that, I am using a method in the component but I am getting an error which says "[js] Unexpected token. A constructor, method, accessor, or property was expected." when I declare that method. Can anyone help to solve that error?
code:
class App extends Component {
state = {
videos: []
};
YTSearch({ key: API_KEY, term: "surfboards" }, function(data) {
console.log(data);
});
render() {
return (
<div>
<SearchBar />
</div>
);
}
}
error:

YTSearch, with that object and function as the parameters. What was your intention?