It’s been awhile since I did any frontend work. Is there something that has taken jQuery’s place?

  • Nerd02@lemmy.basedcount.com
    link
    fedilink
    English
    arrow-up
    8
    ·
    11 months ago

    Axios for requests - easier than working with the Fetch API in some cases

    May I ask what cases? I used to use Axios on Node, before they implemented the fetch API over there but I haven’t touched it since. And defintiely never used it on the client. Could you make an example of some case where it’d be easier to work with Axios than with fetch?

    • 𝒍𝒆𝒎𝒂𝒏𝒏@lemmy.one
      link
      fedilink
      arrow-up
      6
      ·
      11 months ago

      For me it’s the ability to set up a shared instance with the base request URL, and set headers for things like the user’s token, allowing all requests made with that shared Axios instance to be sent to the right path with the token without needing to define them for each individual request.

      To be honest though something similar can be done with spread syntax in the Fetch API’s options parameter