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

254
Views
How to update UI after decreasing qtty from backend in react JS?

When I reload the page then quantity is being updated but until page reload quantity does not update on UI. On the other hand, my database decreasing the quantity.

const StockUpdate = () => {
const { id } = useParams();
const [stockUpdate, setStockUpdate] = useState({});
useEffect(() => {
    const getItemById = async () => {
        const url = `http://localhost:8000/inventory/${id}`
        const { data } = await axios.get(url);
        setStockUpdate(data);
    }
    getItemById();
}, [id]);

const handleDeliveryButton = () => {
    console.log(stockUpdate)
    const item = stockUpdate;
    const url = `http://localhost:8000/inventory/${id}`;
    fetch(url, {
        method: 'PUT',
        headers: {
            'Content-type': 'application/json',
        },
        body: JSON.stringify(item),
    })
        .then(res => res.json())
        .then(data => {
         
            console.log(data)
        });
    toast('Stock quantity updated after delivery !!!!');

};
over 4 years ago · Santiago Trujillo
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!