Error Inserting into Supabase: Type of 'await' operand must either be a valid promise or must not contain a callable 'then' member

28 views Asked by At

I'm getting this error

Type of 'await' operand must either be a valid promise or must not contain a callable 'then' member.deno-ts(1320)

In my Subapase Edge Function whose code is as follows:

import { createClient } from "https://cdn.skypack.dev/@supabase/supabase-js";

const supabase = createClient('https://mylink.supabase.co', 'mykey')

Deno.serve(async (req) => {
  const { email, password, first_name, last_name, username } = await req.json()

  const { error: insertError } = await supabase.from('Users').insert([{ email, password, first_name, last_name, username }])

  if (insertError) {
    // Handle the error
  } else {
    // Handle the successful insert
    console.log('Inserted data:', data);
  }

  return new Response(JSON.stringify(data), { headers: { 'Content-Type': 'application/json' } })
})

This line specifically is giving me the error:

  const { error: insertError } = await supabase.from('Users').insert([{ email, password, first_name, last_name, username }])
1

There are 1 answers

0
Derek Williams On

try changing

const supabase = createClient('https://mylink.supabase.co', 'mykey')

to

const supabase = await createClient('https://mylink.supabase.co', 'mykey')