What's new

Help Tanong - regarding ASYNC in REACT JS

Wu_Fei

Eternal Poster
Established
Joined
Jul 25, 2021
Posts
820
Reaction
797
Points
468
good day po .. tanong ko lang po ..

ano po bang ibig sabihin ng ASYNC po dito ? \

JavaScript:
const fetchUsers = async() => {
        const headers = { 'Content-Type': 'application/json' }
        fetch("http://172.12.14.40:4200/allusers", { headers })
        .then(res => res.json())
        .then(resJson => setList(resJson.data))
        .catch(error=>alert(error))
      }

salamat po <3
 
Matagal na ako di naka frontend pero as far as I know...

Di sya specific sa react. Bale return nya is Promise. Di nya agad icall yang URL until icall mo using await.
Pwede mo pag sabayin icall 2 async calls, or in sequence.

let users = await fetchUsers();
 
Matagal na ako di naka frontend pero as far as I know...

Di sya specific sa react. Bale return nya is Promise. Di nya agad icall yang URL until icall mo using await.
Pwede mo pag sabayin icall 2 async calls, or in sequence.

let users = await fetchUsers();
opo .meron ka po await pa yan sa baba ..

salamat po ng maramig sa help
 

Similar threads

Back
Top