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

  • Nerd02
    link
    fedilink
    English
    81 year 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?

    • 𝒍𝒆𝒎𝒂𝒏𝒏
      link
      fedilink
      71 year 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