It's a fetch() talk…

yeva USA
1 min readJul 2, 2021

In a world where almost everyone is in the rush, we have to make sure that the website page opens quickly enough before the user shuts it down. Asynchronous JavaScript And XML (AJAX) is the technic that helps us to solve this problem and that uses several technologies such as promises or JSON. The fetch() function is a global method on the window object that combines technologies needed for AJAX to work.

Fetch() takes a URL that contains data as an argument and returns the object of that data. In other words, fetch() makes a network request and uses Promises for that. The example looks like that :

fetch(“URL you want to use”)

Because fetch() is using promises, we have to call then() method to the stored object and transform it into a response that can be manipulated. In this function, we can do any processing we need but we must make sure that its response is converted by using json() built-in function and returned.For example :

.then(response => response.json())

After that, we should use final .then method on the object that we got from fetch() and add DOM manipulations to it.

--

--

yeva USA
0 Followers

Hello everyone! I am a student in full stuck code academy and a full time employee in medical office. Worked as animal rescue for some time.