Complete the code to call an Edge Function named 'hello' using Supabase client.
const { data, error } = await supabase.functions.[1]('hello')The correct method to call an Edge Function from the Supabase client is invoke.
Complete the code to send a POST request with JSON body to the Edge Function 'hello'.
const { data, error } = await supabase.functions.invoke('hello', { method: '[1]', body: JSON.stringify({ name: 'Alice' }) })To send data to an Edge Function, use the POST method.
Fix the error in the code to correctly parse JSON response from the Edge Function.
const response = await supabase.functions.invoke('hello'); const data = await response.[1]()
The response from an Edge Function is parsed as JSON using json() method.
Fill both blanks to correctly handle errors and log the data from the Edge Function call.
const { data, error } = await supabase.functions.invoke('hello', { method: 'POST' });
if ([1]) {
console.error(error);
} else {
console.log([2]);
}Check if error exists to handle errors, otherwise log the data.
Fill all three blanks to send a GET request with a custom header and parse the JSON response.
const response = await supabase.functions.invoke('hello', { method: '[1]', headers: { '[2]': 'application/json' } }); const data = await response.[3]()
Use GET method, set header Content-Type to 'application/json', and parse response with json().