14

http requests

literally the bread and butter of any software engineer building applications, you would ASSUME they know what they are doing...

and you're gonna write a seperate http get and post function for every type you have?

apparently stuff like this that is written by "senior" developers? you don't even have a basic understanding of software...

i'm won't do it that way, becuase i'm an adult, not a child

what i'm going to do is write a HTTP request util function that can be used for any type and HTTP verb. DRY, single responsibility, etc.

imagine making the http request itself a responsibility coupled to the type 😂😂😂😂

get a clue and come back later

i can't tell anymore if my thoughts are so outlandish compared to everyone else that no one understands them, or if i've been doing this so long that i just immediately understand what needs to be done and don't know how to explain it to anyone else anymore (or take the mental effort to)

peace out

oh P.S.: imagine thinking the SOLID principles are only applicable to OOP

stay safe out there folks, its getting more painful every day

Comments
  • 3
    wait u do a function that can be used as either post or get, omg. 😦. Thats so much brain.
  • 1
    idk due ._.
    1 function for GET/POST usually clutters up the method call

    separate one is cleaner to maintain, even easier then to #region them per-object
  • 1
    Depends on your abstraction really:

    1. Core code depends on RepositoryInterface

    2. Repository implements RepositoryInterface and the actual API with some 3rd party HTTP library (spoiler: it's cURL)

    3. ???

    4. Profit!

    Your core code is now testable and does not depend on concrete implementation details of the actual API.
  • 0
    The number of misconceptions regarding HTTP is... Enormous.

    https://evertpot.com/get-request-bo...

    Read this for example.

    The number one misconception is usually what the HTTP verbs imply...

    ... The next one regarding idempotency and what HTTP verbs *behaviour* should be.

    Then we come to the point of "No. Not everything is UTF-8… its ASCII."...

    To finish up with "no, headers / queries / post bodies" have a limit regarding their size which *must* be respected.
  • 0
    Endpoint handling by path(/someresource/<ID>) and then verb(get/post/delete[mostly used by native clients not browser]) used, with a catchall at the end for error handling aka return root Index.html.

    REST api or even actual Web serving infra.
  • 2
    Even easier: just POST everything
  • 1
    Not every verb needs a method. A save method can determine if it's a create (post) or update (put). It's also common to just build a request and send that request. The verb does not matter if request is your abstraction layer.

    Edit: ah I read it wrong. Self.httpVerb() is three crap the senior produces if I'm not mistaken. Hope the language supports traits to make the boilerplate manageable.
  • 0
    I usually export http_client object that exposes get post put and del objects which are wrappers functions around around the underlined http verbs exposed by an axios instance
    Then with interceptors attached to My axios instance I can catch all non 2xx response and make sure to trigger a logout and clean up as soon as I hit a 401
Add Comment