5 ms·
Everyone here seems to be talking about how great jQuery was for DOM interaction and that's true. But the other thing that was life changing about it was how ea
by jcuenod 4y ago
Everyone here seems to be talking about how great jQuery was for DOM interaction and that's true. But the other thing that was life changing about it was how easy it was to make ajax requests!
- mindcrime 4y agoBut the other thing that was life changing about it was how easy it was to make ajax requests! What's the "modern" alternative to jQuery in that regard? I don't do much JS development, but if I needed to make an AJAX request today, my first instinct would probably still be to use jQuery.
- osrec 4y agoGoogle the Fetch API.
- mindcrime 4y agoThanks!
- psnehanshu 4y agoFetch API is fine, but Axios[0] gives you a lot more flexibility. The best thing I like is the request/response interceptor. You can do cool stuff like injecting tokens into outgoing requests, retry failed requests, centralized error handling. Because of adapters, it works both in browser environment as well as Node.js environment. Heck, you can even mock requests in your unit tests using a mock adapter[1] to avoid making actual HTTP requests. Sure there is a cost for adding dependency when you can just use native APIs, but in this case, I think it's worth it. [0] https://axios-http.com/ https://axios-http.com/ [1] https://www.npmjs.com/package/axios-mock-adapter https://www.npmjs.com/package/axios-mock-adapter
- deleted 4y ago[deleted]
- ishjoh 4y agofetch: https://developer.mozilla.org/en-US/docs/Web/API/fetch https://developer.mozilla.org/en-US/docs/Web/API/fetch