Handling ajax with React

前端 未结 5 1053
南笙
南笙 2020-12-02 13:11

How should I handle ajax requests in a fairly traditional web application? Specifically with using React for views, while having a backend that handles data such as text and

5条回答
  •  爱一瞬间的悲伤
    2020-12-02 14:07

    Kindly checkout the official documentation of Facebook about Complementary Tools at https://github.com/facebook/react/wiki/Complementary-Tools

    They simply recommends few data fetching API's like

    • axios: Promise based HTTP client for the browser and node.js.
    • jQuery AJAX: No introduction needed.
    • superagent: A lightweight "isomorphic" library for AJAX requests.
    • reqwest: AJAX all over again. Includes support for xmlHttpRequest, JSONP, CORS, and CommonJS Promises A. Browser support stretches back to IE6.

    My personal favorite would be axios due to promises which works in browser as well as in nodejs env and even officially reactJS website recommend the same at AJAX and APIs

提交回复
热议问题