Hello I hope someone can give me some advice.
I’m currently having this issue that the json response body is invalid:
FetchError: invalid json response body at http://hippiekick.byethost3.com/wp-json/wp/v2/posts?_embed=true&slug=startsida reason: Unexpected token < in JSON at position 0
at eval (webpack-internal:///./node_modules/node-fetch/lib/index.mjs:276:32)
at eval (webpack-internal:///./node_modules/@frontity/react-easy-state/dist/bundle.js:58:245)
at batchedUpdates$1 (webpack-internal:///./node_modules/react-dom/cjs/react-dom.development.js:3767:145)
at batch (webpack-internal:///./node_modules/@frontity/react-easy-state/dist/bundle.js:58:237)
at Object.apply (webpack-internal:///./node_modules/@frontity/react-easy-state/dist/bundle.js:61:179)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at Object.populate (webpack-internal:///./node_modules/@frontity/wp-source/src/libraries/populate.ts:27:12)
at Object.eval (webpack-internal:///./node_modules/@frontity/wp-source/src/libraries/handlers/postType.ts:35:217)
at eval (webpack-internal:///./node_modules/@frontity/wp-source/src/actions.ts:40:1)
I found this thread which shows the person had the same issue I believe. So I tried to implement solution in the menu-handler and it doesn’t seem to make any difference. This is what it looks like in my menu-handler:
const menuHandler = {
name: "menus",
priority: 10,
pattern: "/menu/:slug",
func: async ({ link, params, state, libraries }) => {
console.log("PARAMS:", params);
const { slug } = params;
// Fetch the menu data from the endpoint
const response = await libraries.source.api.get({
endpoint: `/menus/v1/menus/${slug}`,
params: {
head_tags: false // This one should disable REST API - Head Tags.
}
});
// Parse the JSON to get the object
const menuData = await response.json();
// Add the menu items to source.data
const menu = state.source.data[link];
console.log(link);
Object.assign(menu, {
items: menuData.items,
isMenu: true,
});
},
};
export default menuHandler;
And I was wondering why is the menu registered as a Custom Post Type and not a page is it possible to change this?
Thank you in advance!