Updated the code to allow for images

This commit is contained in:
Tiago Ribeiro
2024-04-01 00:50:53 +01:00
parent 1c5f16d42b
commit 3359c47379
24 changed files with 91 additions and 49 deletions

View File

@@ -13,11 +13,10 @@ interface StrapiResponse<T> {
meta: object;
}
type Result<T> = {data: StrapiResponse<T>; isError: boolean};
export async function getData<T>(page: string, locale: "ar" | "en"): Promise<Result<T>> {
export async function getData<T>(page: string, locale: "ar" | "en"): Promise<T> {
const request = await axios.get<StrapiResponse<T>>(`${process.env.STRAPI_URL}/api/${page}/?populate=deep&locale=${locale}`, {
headers: {Authorization: `Bearer ${process.env.STRAPI_TOKEN}`},
});
return {data: request.data, isError: request.status !== 200};
return request.data.data.attributes;
}