I am trying to bring the courses from the end point that a plugin generates.
Handler
export const routeCourseArchive = {
name: "courses",
priority: 8,
pattern: "/courses",
func: async ({ route, state, libraries }) => {
// 1. get all Courses
const coursesList = await libraries.source.api.get({
endpoint: "/llms/v1/courses"
});
// 2. add everything to the state.
const items = await libraries.source.populate({
response: coursesList,
state
});
// 3. add info to data
Object.assign(state.source.data[route], {
GeneralTitle: 'Learning',
isArchiveCourses: true,
isPostType: true,
type: "course",
items: items.map(item => ({
type: item.type,
id: item.id,
link: item.link
}))
});
}
}
frontity.settings.js
"postTypes": [
{
"type": "course",
"endpoint": "/llms/v1/courses",
"archive": "/courses",
}
]
ServerError: post type from endpoints “posts,pages,media” with slug coursesundefined" not found