I keep getting the following error while trying to...
# javascript
s
I keep getting the following error while trying to insert data into a table
Copy code
{
  hint: null,
  details: null,
  code: '42703',
  message: 'column "0" of relation "intervals" does not exist'
}
Couldn't find anything on this, and I even temporarily removed my relation keys from the tables to just see if plain inserting something would work but I'm still getting the error. Any ideas why this is happening? If it helps, here's my next.js api route code
Copy code
// req.body is an object containing the fields I want the row to have
  console.log("REQ: ", req.body)
  const { data, error } = await supabase
    .from("intervals")
    .insert([req.body])
  if (error) {
    console.log(error)
    res.status(404)
  }
  console.log("NICE: ", data)
  res.status(200).json(data)
s
Can you dump out what is in
req.body
, as I am sure it has data in there which isn't part of the table you are trying to insert into. Also you have wrapped it with an array, this could be an issue if
req.body
doesn't have multiple objects inside of it.
s
@User I'll double check in a bit but I'm pretty sure
req.body
is a single object with the 1 required prop for the insert. In regards to the array, the supabase docs example for the
insert
method use an array to insert only one object as well, and I'm pretty sure it worked for another table I have where I tried to insert rows
s
The error is that
req.body
has a property of 0 which is not a column in the intervals table. So it’s either
req.body
is empty or it actually contains that column.