N
N
nikita_chiru2017-08-23 16:46:04
JavaScript
nikita_chiru, 2017-08-23 16:46:04

How to get data from firebase and display it in a list?

How to display data from firebase on pure js + html and list it in html?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Victor L, 2017-08-23
@Fzero0

well... like this

function MenuView (obj) {
    return `<li id="${Object.keys(obj)}">${Object.values(obj)}</li>`
  }
const fetchMenu = async (name) =>{
  const url = `https://testprese.firebaseio.com/${name}/.json`;
  const response = await fetch(url);
  return await response.json();
}
(async ()=>{
  const menu = await fetchMenu ("menu");
  let list = '';
  menu.forEach((item) => {list += MenuView(item);});
  document.getElementById('menu').innerHTML = list;
})();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question