DEV Community

Cover image for fetch( kungFu )
Ben Limpic
Ben Limpic

Posted on

fetch( kungFu )

Aloha amigos!

I hope this blog is the start of an exciting tradition. I have always been a bit shy when writing about myself. I feel weird even keeping a journal. I don't know where I picked up on the habit of disregarding documentation but here's to making progress and writing it down.

It has been a while since I took time out to pursue rigorous study. I have often wished I could jump back into the thick of it. But, we all know what it's like, being somewhere a while and then dreaming of a greener pasture. So here I am, trying my hand at uncovering the mysteries of computer magic.

The title of this post may be a bit confusing to those of you who haven't completed an introductory course in Javascript, so let me explain. First, there is no shortcut to learning. But, if there were, maybe it would look like this.

When we utilize a fetch request, we ask an outside source, a server, for information. We do this by providing the fetch function with a URL to a destination containing the data we want to use. Once the GET request is received, a response fires back to the fetch called a promise. Think of a promise as a gift certificate. After we use the .then() method to verify whether we are exchanging our certificate for a lovely present or not, we are ready to unwrap our gift using .json(). We do so, and after another .then() request (where we figure out what to do with the damn thing), we are ready to use our brand new data!

Wouldn't it be nice if we could send a fetch request in our mind and instantly learn something new in a snap? Maybe one day, we will all blow on the dusty card of a mortal combat cartridge and click that sucker into the back of our heads. Like Neo said... "I know kung fu."

Top comments (0)