I’ve created a cardsByLanguage promise in my api file for my projected, inserted a navbar item for for a filtered results search, and created a click event listener for this navbar item, but no cards display. In my promise, I first filtered for language and then by uid, so both options should be filtered.
I put the following function for my api js file:
`const cardsByLanguage = (language, uid) => new Promise((resolve, reject) => {
fetch(`${endpoint}/vocab.json?orderBy="language"&equalTo="${language}"`, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
})
.then((response) => response.json())
.then((data) => {
const filteredData = Object.values(data).filter((card) => card.uid === uid);
resolve(filteredData);
})
.catch(reject);
});`
And I’ve put the following for a navbar click event listener:
`document.querySelector('#allLanguages').addEventListener('click', () => {
cardsByLanguage(`${firebase.auth().currentUser.uid}`).then(showCards);
});`