just add data to return json
const api = new GhostContentAPI({
url: "https://ali-atwa.digitalpress.blog",
key: "bef5171833fd701e51903f181e",
// @ts-ignore
makeRequest: ({ url, method, params, headers }) => {
const apiUrl = new URL(url);
// @ts-ignore
Object.keys(params).map((key) =>
apiUrl.searchParams.set(key, encodeURIComponent(params[key]))
);
return fetch(apiUrl.toString(), { method, headers })
.then(async (res) => {
// Check if the response was successful.
if (!res.ok) {
// You can handle HTTP errors here
throw new Error(`HTTP error! status: ${res.status}`);
}
return { data: await res.json() };
})
.catch((error) => {
console.error("Fetch error:", error);
});
},
version: "v5.0",
});