JCombe
JCombe

Reputation: 27

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

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

enter image description here

Upvotes: 0

Views: 22

Answers (2)

JCombe
JCombe

Reputation: 27

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

Upvotes: 0

Sarah
Sarah

Reputation: 344

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
}

Upvotes: 1

Related Questions