shadcn 의 data table에서 strapi 결과 처리

HGW XX/7·2024년 5월 19일

strapi 로 백엔드 만들고 shadcn 의 data table 로 처리하려고 하니 안되는게 있었다.

아래와 같이 p => p.attributes 로 처리해주니 정상 작동

export async function getData() {
  const res = await fetch(`http://localhost:1337/api/databases`, {
    cache: 'no-store',
  });
  // const res = await fetch(`https://nomad-movies.nomadcoders.workers.dev/movies`);
  const data = await res.json();
  // console.log(data.data);
  const result = data.data.map((p: any) => p.attributes);
  console.log(result);
  return result;
}

0개의 댓글