#getStaticPaths Fetching data

18 messages · Page 1 of 1 (latest)

brittle ruin
#

Hey! i have an app with Astrojs - TailwindCSS & Strapi but i got a problem cause **I do'nt know nothing about gsp ( GetStaticPaths ) so with Strapi i got an slug generator but i wanna make an page for each product on my api and use the slug to the page, Can anyone help me please?

hardy shard
brittle ruin
hardy shard
#
export async function getStaticPaths() {
  const articles = await fetchApi<Article[]>({
    endpoint: 'articles',
    wrappedByKey: 'data',
  });

  return articles.map((article) => ({
    params: { slug: article.attributes.slug },
    props: article,
  }));
}

type Props = Article;

const article = Astro.props;
#

we have a guide on how to set Astro with Strapi as well

#

have you taken a look at it?

#

@brittle ruin

brittle ruin
#

Sorry @hardy shard I Wasnt home

#

lemme see

#

Theres something that i was never understand when u write this

fetchApi <Article[]>(){}```

its literally?
#

or what is <Article[]>?

hardy shard
#

a type

#

I recommend you to take a look to the guide that I just linked and see if you can manage to achieve what you're trying to do.

brittle ruin
#

Alr men

#

Ty!

hardy shard
#

np, anytime

brittle ruin
#

@hardy shard uh?