Puas yog fetch API asynchronous?
Puas yog fetch API asynchronous?

Video: Puas yog fetch API asynchronous?

Video: Puas yog fetch API asynchronous?
Video: Synchronous vs Asynchronous Programming in JavaScript in Hindi 2024, Kaum ib hlis
Anonim

Asynchronous Fetching (Cov lus cog tseg)

Lub neej ntawd txhais tau tias nqa cov ntaub ntawv nrog nqa yog raws li kev cog lus. Xav tias peb daim ntawv thov yuav tsum tau nqa cov ntaub ntawv los ntawm ib tug muab url, ntawm no yog ib txoj kev peb nqa tuaj yeem saib. Txhua yam zoo, peb tau nqa peb cov ntaub ntawv thiab nws rov qab los ua ib qho array - tshwm sim.

Dhau li ntawm no, yog fetch asynchronous?

rauTxhua yog synchronous , thaum nqa yog asynchronous . Thaum txhua lub ntsiab lus ntawm cov txiaj ntsig array yuav raug mus xyuas hauv kev txiav txim, rauEach yuav rov qab los yam tsis tau ua tiav nqa , yog li cia koj npliag tes.

Kuv yuav siv tau API li cas? Nyob rau hauv ib qho yooj yim heev txhua yam koj yeej ua yog hu nqa nrog rau qhov URL koj xav tau, los ntawm lub neej ntawd Siv API siv txoj kev GET, yog li kev hu yooj yim heev yuav zoo li no: nqa (url) // Hu rau nqa muaj nuj nqi dhau qhov url ntawm tus API raws li ib tug parameter.

Kuj nug, dab tsi yog qhov fetch API?

Cov Siv API muab JavaScript interface rau kev nkag mus thiab tswj qhov chaw ntawm HTTP pipeline, xws li kev thov thiab cov lus teb. Nws kuj muab lub ntiaj teb no nqa () txoj kev uas muab ib qho yooj yim, txoj kev xav kom nqa cov ntaub ntawv asynchronously hla lub network.

Isomorphic fetch yog dab tsi?

TUAJ yog polyfill rau browsers uas tsis muaj nqa muaj nuj nqi (caniuse.com/#search= nqa ). Nws yuav ntxiv nqa ua haujlwm rau koj qhov browser qhov rai qhov khoom. Thaum isomorphic - nqa yog kev siv ntawm nqa rau ob lub node. js thiab browser, ua rau saum nqa polyfil.

Pom zoo: