Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

403
Views
How can I wait in .then() block to get a value and display it in innerHTML?

I am using firebase firestore database vesion 9 . I am working on a Notes App project and what i am trying to do here is that whenever i click on new note the new note gets created with empty content in database and i want to fetch its id to show on top of note. Here is the code of the Problem I am facing:-

    let docId;
    addDoc(colref,{
    notes: "",
    EditedAt: serverTimestamp()
    })
     .then((el)=>{
                 docId = el.id;
                 console.log(docId)
                 })
     .catch(err=>{
                 console.log(err.message);
                 })

note.classList.add('note')
note.innerHTML = `
<div class="tools">
<span class="doc-id">${docId}</span>
    <button class="edit"><i class="fas fa-edit"></i></button>
    <button class="delete"><i class="fas fa-trash-alt"></i></button>
</div>
<div class="main ${text ? "" : "hidden"}"></div>
<textarea class="${text ? "hidden" : ""}"></textarea>
`
document.body.appendChild(note)
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!