Select Your Wellness Goals




type="checkbox" class="goal" value="Mobility Support"> Mobility Support
async function getBlend() { const res = await fetch( "https://hddqvfseiwnerorfjxyt.supabase.co/functions/v1/blend-api", { method: "POST", body: JSON.stringify({ action: "recommend", goals: selectedGoals, flags: userFlags }) } ) return await res.json() } document.getElementById('get-recommendation').addEventListener('click', async () => { // 1. Gather the checked goals const selectedGoals = Array.from(document.querySelectorAll('.goal:checked')) .map(cb => cb.value); // 2. Placeholder for user flags (or set as empty array for now) const userFlags = []; const resultsDiv = document.getElementById('results'); resultsDiv.innerText = "Consulting the herbalist..."; try { // 3. Call the function you already pasted const data = await getBlend(selectedGoals, userFlags); // 4. Display the recommendation resultsDiv.innerText = "Recommended Blend: " + (data.recommendation || "No blend found."); } catch (error) { resultsDiv.innerText = "Error fetching blend. Please try again."; console.error(error); } });