Hi all
Im new in Frontity and Im trying to get data of template_parts.
I reed this conversation and tried to do everything as there was mentioned and its not work for me. After that I decide to check REST API data directly and get it by url of my localhost https://localhost/wp-json/wp/v2/template-parts and its not working.
This is the error message which I get:
{"code":"rest_no_route","message":"No route was found matching the URL and request method.","data":{"status":404}}
But for https://frontity.org/wp-json/wp/v2/template-parts its working and there is tons of data.
Why its happening, maybe someone know ? Should I activate something or etc ?
Wordpress Version: 5.9.3
Theme: Twenty Twenty-Two
/packages/my-theme/src/index.js
state: {
theme: {
templates: [ "footer" ]
},
},
actions: {
theme: {
beforeSSR: async ({ state, actions }) => {
await Promise.all(
[
state.theme.templates.map((slug) =>
actions.source.fetch(`/wp_template_part/${slug}`)
),
]
);
},
},
},
front/packages/my-theme/src/components/index.js
import React from "react"
import { connect } from "frontity"
const Root = ({ state }) => {
const data = state.source.get(state.router.link)
const footer = state.source.get("/wp_template_part/footer")
console.log(footer);
return (
<>
<h1>Hello Frontity</h1>
<p>Current URL: {state.router.link}</p>
</>
)
}
export default connect(Root)
front/frontity.settings.js
"state": {
"source": {
"url": "http://localhost/",
postTypes: [
{
type: "/wp_template_part",
endpoint: "template-parts",
},
],
}
}