DEV Community

Cover image for Make fetch better and your API request methods easier to implement

Make fetch better and your API request methods easier to implement

Simon Ström on October 11, 2020

In this post, I will share my thought on how I like to structure methods on how to get data from your REST API backend. The idea here is to show th...
Collapse
 
srikanth597 profile image
srikanth597 •

Nice post

Collapse
 
stroemdev profile image
Simon Ström •

Thanks, glad you enjoyed it!

Collapse
 
opimand profile image
opimand •

Oh, good tutorial. You save a lot my time 👍

Collapse
 
stroemdev profile image
Simon Ström •

Awesome! More time spent doing fun stuff

Collapse
 
gaidygomez profile image
gaidyjg •

Great post. This makes me remember the functionalitys of packages HttpClient of PHP. This is very useful for simplify of the handle http request's. Thanks for the tutorial.

Collapse
 
stroemdev profile image
Simon Ström •

Cool! My experience with PHP is limited though. The inspiration is from my background doing C# and their httpclient class. Glad you liked it!

Collapse
 
raghavmisra profile image
Raghav Misra •

The C# HTTPClient is exactly what I was thinking about while reading this. Great post!

Thread Thread
 
stroemdev profile image
Simon Ström •

Its always good to look at other languages some times to find inspiration. Thank you!

Collapse
 
inacior profile image
Renan Inácio •

Nice way to use classes in JS, with extends

Collapse
 
stroemdev profile image
Simon Ström •

Yeah, when looking at docs for classes all examples of extending is these things like animal extending to dog or car extending to Honda. So it is Nice with a more "real world" context for extending.

Collapse
 
fellipegpbotelho profile image
Fellipe Geraldo Pereira Botelho •

Nice article!

Collapse
 
stroemdev profile image
Simon Ström •

Thank you!

Collapse
 
marcbaumbach profile image
Marc Baumbach •

Nice article! The HttpClient in your example code is using "POST" for the the HTTP method when calling the "put" function on it. Great little wrapper around fetch, though. :)

Collapse
 
stroemdev profile image
Simon Ström •

Oh! Always good with an extra pair of eyes on your code, thank you :-)

Collapse
 
leonavevor profile image
leonavevor •

Nice and cool

Collapse
 
stroemdev profile image
Simon Ström •

Thanks!