I am learning firebase with next.js. I would like to bring data from firebase to display. I am connected to firebase, but my output is not working. Can you please tell me whot I am doing wrong? Thank you
folder libs:
export async function Ids() {
let output = []
try {
const data = await firebase.collection('database').get()
data.forEach(doc => {
output.push({
params: {
id: doc.id,
...doc.data()
}
})
})
} catch (err) {
console.log(err)
}
return output;
}
folder pages / index.js
import { Ids } from '../lib/resources'
export async function getStaticProps() {
const itemData = await Ids()
return {
props: { itemData }
}
}
export default function Home( {itemData} ) {
return (
<>
<h2 className="text-center mt-5">Data</h2> // it show me only this h2 statement
{
itemData ?
itemData.map( (doc) => {
<p className="text-center" key={doc.id}>{doc.title}</p>
}) : null
}
</>
)
}