How to refresh an api call on click event?

Oh, and I tried this, but it generates a javascript error in the console.