#I see the content in the console but not on the page

3 messages · Page 1 of 1 (latest)

dense olive
#

Please can anyone help take a look a this code and tell me how I can fix it. This is my src/pages/articles/[...slug].astro file. I am pulling a single record from my Supabase DB that matches the slug parameter.

---
import { supabase } from "../../supabase";

const { slug } = Astro.params;
const res = await supabase.from("articles").select("*").eq('slug', slug)
const article = await res.data

if (!article) return Astro.redirect("/404");

console.log(slug)
console.log(article)

---

<html>
<head>
  <title>{article.title}</title>
</head>
<body>
  <h1>{article.title}</h1>
  <p>{article.content}</p>
</body>
</html>
cunning nicheBOT
#
Quiet in here?

It looks like no-one has responded to your question yet. People might not be available right now or don’t know how to answer your question. Want an answer while you wait? Try asking our experimental bot in #1095492539085230272.

wise topaz
#

It looks like article is an array. try const article = await res.data[0]