The problem is listed in your screenshot:
It’s saying xhr
isn’t available in the server-side environment in which you’re trying to use the content API library.
I think your options are either providing a custom makeRequest
function to the Content API library with a http library that’s supported in your environment in place of axios
or making requests to the API directly without using the library wrapper.
Example of supplying a custom request function that uses fetch
in place of axios
(I’ve not tested this, it’s just an example to work from for your own use-case):
const api = new GhostContentAPI({
url: process.env.GHOST_URL,
key: process.env.GHOST_KEY,
makeRequest: ({url, method, params, headers}) => {
const apiUrl = new URL(url);
Object.keys(params).map(key => apiUrl.searchParams.set(key, encodeURIComponent(params[key]);
return fetch(apiUrl, {method, headers}).then(res => res.json());
}
};