Home > database >  Why is my external function getting called on page load? JS
Why is my external function getting called on page load? JS

Time:06-18

Why is my external function automatically getting called on page load even though I didnt call it?enter image description here

CodePudding user response:

It looks like line 14 of fetchRandomUser.js is calling the function that you want to export. I would omit line 14 and change line 3 to

export default async function fetchRandomUser() {
    // some code here
}

CodePudding user response:

I exported my function with "export default funcName;" instead of using "export async function funcName() {...}"

  • Related