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

200
Views
Hot to get a value of a document in Firebase V9 using JavaScript

When I use the setNumberOfExpensesOfTheCar() it is not saving the value, however when I do a console.log() of it it prints correctly.

It doesn't matter if I use line 4 or 5, the value is not saved

Nn line 6 you don't see the print but on lines 7 and 8 yes.

What am I doing wrong?

Thank you very much and sorry if the format is not correct. (It's my first post)

1. const [numberOfExpensesOfTheCar, setNumberOfExpensesOfTheCar] = useState("");
2. const actualCarRef = doc(db, "vehicles", actualCar);
3. const actualCarSnap = await getDoc(actualCarRef);

4. setNumberOfExpensesOfTheCar((actualCarSnap.get("numberOfExpenses")).toString());
5. setNumberOfExpensesOfTheCar((actualCarSnap.get("numberOfExpenses")));

6. console.log(numberOfExpensesOfTheCar);
7. console.log(actualCarSnap.get("numberOfExpenses").toString());
8. console.log(actualCarSnap.get("numberOfExpenses"));

``
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!