window.function = async function (userId, email) { // Default values if not provided userId = userId.value ?? ""; email = email.value ?? ""; // URL to your server function that generates the SSO payload const url = 'https://asia-southeast1-synergywellness.cloudfunctions.net/function-sso-3?userId=${userId}&email=${email}'; try { const response = await fetch(url); if (!response.ok) { throw new Error('Network response was not ok'); } const data = await response.json(); // Adjust based on your server response return data.ssoPayload; // Adjust this based on the actual key in your response } catch (error) { console.error("Fetch error:", error.message); return undefined; // Return undefined to indicate an error occurred } }