I want to take some data from firebase real time db and add them as the inital value for a dynamic form
get(child(dbRef, `links/${dummy.prefix}/links/links`)).then((snapshot) => {
if (snapshot.exists()) {
const dummy = snapshot.val();
setAlllinks(dummy)
for(var i in dummy){
setTheArray([...theArray, { "links" : [dummy[i]['first'], dummy[i]['last'] ]}]);
}
} else {
console.log("No data available");
}
}).catch((error) => {
console.error(error);
});
This is the data that i get from firebase and add it to thearray
[
{
"first": "https://google.com",
"last": "google"
}
]
const availablelinks = {
links: theArray
};
const itemInputs = availablelinks.links.map((item) => {
return {
first: item.first,
last: item.last,
};
});
for more details please see the git repohere
