refining taxonomy js to handle load more button and connect to custom api endpoint
This commit is contained in:
parent
c702ea0e54
commit
1fc4e1ebc6
|
|
@ -1,20 +1,20 @@
|
|||
async function fetchMoreThematiquePostDatas() {
|
||||
// const response = await fetch('/wp-json/wp/v2/questions?per_page=100');
|
||||
const response = await fetch('/wp-json/wp/v2/questions?thematiques=41');
|
||||
async function fetchMoreThematiquePostDatas(id) {
|
||||
const response = await fetch(`/wp-json/homegrade-datas/v1/questions-thematiques/${id}`);
|
||||
|
||||
const data = await response.json();
|
||||
console.log(data);
|
||||
return data;
|
||||
}
|
||||
|
||||
async function handleLoadMoreClick() {
|
||||
const posts = await fetchMoreThematiquePostDatas();
|
||||
const currentTermId = mainAppJsDynamicDatas.current_thematique.term_id;
|
||||
const posts = await fetchMoreThematiquePostDatas(currentTermId);
|
||||
console.log(posts);
|
||||
const postsContainer = document.querySelector('.post-question-page__accordeons-container');
|
||||
console.log(mainAppJsDynamicDatas.current_thematique);
|
||||
posts.forEach((post) => {
|
||||
let newContent = createDetailsElement(post);
|
||||
postsContainer.appendChild(newContent);
|
||||
});
|
||||
// console.log(posts);
|
||||
// posts.forEach((post) => {
|
||||
// let newContent = createDetailsElement(post);
|
||||
// postsContainer.appendChild(newContent);
|
||||
// });
|
||||
}
|
||||
|
||||
function createDetailsElement(post) {
|
||||
|
|
@ -44,7 +44,7 @@ function createDetailsElement(post) {
|
|||
}
|
||||
|
||||
export default async function taxonomyThematiqueFaqInit() {
|
||||
console.log(mainAppJsDynamicDatas);
|
||||
// console.log(mainAppJsDynamicDatas);
|
||||
const currentQuestionPage = document.querySelector('.post-question-page');
|
||||
const filters = document.querySelectorAll('.thematiques-subtaxonomy-links li');
|
||||
if (!currentQuestionPage) return;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user