
Show HN: Simplifying http requests using ES decorators - jblaak
https://github.com/jblaak/fitted
======
Etheryte
Not sure if I see how this is any different from simply using `<a library of
your choice>.get(...)`. Just a different, imho more confusing, syntax.

~~~
jblaak
For single requests this would, indeed, be the best solution. However, when
exposing an interface to multiple endpoints, requiring the same base url,
pre/post-processing of requests this helped me quite a bit.

~~~
davej
I'm having trouble figuring out how this would look in code and how it would
be more graceful than async/await. Can you share an example?

~~~
jblaak
Sure! Here is a gist:
[https://gist.github.com/JBlaak/8d9fdebb2a28a0b9026a71bced7cc...](https://gist.github.com/JBlaak/8d9fdebb2a28a0b9026a71bced7cceaf)

Every request will have the `accept` and `X-Requested-With` headers and
prefixed with some route prefix using the request and the base decorators. As
you can see in consumer.js you use async/await to consume results generated by
the methods.

