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

137
Views
Display Loading spinner whilst data is fetching

How can show a loading spinner whilst the data is loading to fetch.

const [user, loading, error] = useAuthState(auth);
const navigate = useNavigate()
const [bikes] = useBikes()

if (loading) {
  return  <Loading></Loading>
}
            
fetch(`http://localhost:5000/bike/${id}`, {
    method: 'DELETE'
})
  .then(res => res.json())
  .then(data => {
      console.log(data)
      alert('One Item Deleted')
   });
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

If you have the spinner under the id spinner here's a minimalistic example on how you can do so. just wrap the fetch inside a function.

function delitem(){
  document.getElementByID("spinner").style.display = "block"
  fetch(`http://localhost:5000/bike/${id}`, {
    method: 'DELETE'
    })
    .then(res => res.json())
    .then(data => {
      console.log(data)
      alert('One Item Deleted')
      document.getElementByID("spinner").style.display = "none"
   });
}

about 4 years ago · Juan Pablo Isaza Report

0

Put your fetch API inside the useEffect, so you can easily implement your spinner functionality

const [isLoading,setIsLoading]=useState(false);


useEffect(()=>{
 setIsLoading(true);
 fetch("some-url").then(res=>res.json())
  .then(data=>{
  setIsLoading(false)
  console.log(data);
},[])

if(isLoading){
 return <LoadingSpinner/>
}

return <div>..your data </div>
about 4 years ago · Juan Pablo Isaza Report
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!