Quantcast
Channel: Active questions tagged svelte - Stack Overflow
Viewing all articles
Browse latest Browse all 1541

How to pass in parameters from client side to server side code in Sveltekit?

$
0
0

I've been trying to run a query to a Supabase database that needs a dog breed passed through and will return metrics about it, the breed is defined on the client side. I was able to get the server side query to run but the value is not going through.

+page.svelteexport let metrics;  export let data;  const getAllDogs = async () => {    const { metrics: data } = load({ dog: dog_val });    metrics = data;  };  onMount(async () => {    getAllDogs();  })+page.server.jsimport supabase from "../../lib/db";//Method to get all dog breedsexport const load = async ({dog}) => {  const getAllMetrics = async () => {    try {      let { data, error } = await supabase        .from("dogs")        .select("avg_size, avg_obedience, avg_compassion, avg_health, avg_cleanliness, avg_energy"        )        .eq("Breed", dog);      console.log(data)      console.log(dog)      return data;    } catch (e) {      console.error(e);    }  };  return {    metrics: getAllMetrics(dog)  }};

Viewing all articles
Browse latest Browse all 1541

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>