import { Guitar } from "../type/guitars"; /** * Guitar情報取得処理 */ export const fetchGuitars = async (): Promise => { // StrapiのAPIを呼び出し const response = await fetch( `${process.env.NEXT_PUBLIC_STRAPI_URL}/api/guitars?populate=*` ); // apiのresponseからdata部のみ取り出し const guitars: Guitar[] = await response.json().then((json) => json.data); return guitars; }; /** * Guitar情報取得処理 */ export const fetchGuitarDetail = async (id: string): Promise => { // StrapiのAPIを呼び出し const response = await fetch( `${process.env.NEXT_PUBLIC_STRAPI_URL}/api/guitars/${id}?populate=*` ); // apiのresponseからdata部のみ取り出し const guitar: Guitar = await response.json().then((json) => json.data); return guitar; };