Hey guys, can you help me figure this out - I'm a ...
# help
r
Hey guys, can you help me figure this out - I'm a supabase newbie. So, I am trying to save data that I fetched from an api to my supababse database (using Nextjs), but can't tell where to plug in my supabase related code to 'Insert' the data. Here is what my code looks like
Copy code
export async function getServerSideProps({ req }) {
  //Base Url
  const gBaseUrl = 'https://www.googleapis.com/youtube/v3';

  //Supabase related
  //Insert many rows

  // const { data, error } = await supabase
  // .from('table')
  // .insert([
  //   { some_column: 'someValue' },
  //   { some_column: 'otherValue' },
  // ])

  const channelID = [];

  for (const channel of channelList) {
    const channelData = await fetch(
      `${gBaseUrl}/channels?part=snippet,contentDetails,statistics&id=${channel.channelID}&key=${process.env.YOUTUBE_API_KEY}`
    ).then((res) => res.json());
    channelID.push(channelData.items); // Need to save "channelData.items" coming from YoutubeAPI to the database.
  }

  //Return data
  return {
    props: {
      channelID,
    },
  };
}
What to do?
n
Hello @ReactingMe! This thread has been automatically created from your message in #843999948717555735 a ``few seconds ago``. Want to unsubscrie from this thread? Right-click the thread in Discord (or use the ... menu) and select Leave Thread to unsubscribe from future updates. Want to change the title? Use the
/title
command! Done using the thread? Click the button below to archive it.
Thread was archived by @ReactingMe. Anyone can send a message to unarchive it.
ReactingMe (2022-03-11)