I am building simple sharepoint webpart and i have a problem with using a function in my main file from other module file.
Part of the file JSFunctions.module.js (file where i create my function):
function getApi(){
[my code]...
};
export { getApi }
Part of the file TestWebpartWebPart.ts (main file with body of my webpart):
import { getApi } from './JSFunctions.module.js';
this.domElement.innerHTML = `
<input type="text" id="userEmailInput"><br><br>
<input type="Button" Value="Przycisk" onClick=${getApi()}><br><br>
<div id="html_BirthdayTable"></div>
`;
Everythng is fine with html code, but i have problem wih onClick=${getApi()}.
When i type onClick${getApi()} there is error on the page: "Object(...) os not a function"
When i type onClick${getApi} there is no error on the page but after clicking on the button nothing happens and when i inspect the code on the page o can see onclick="undefined"
The same happens when I tried "export function getApi(){}" in the JSFunctions.module.js file