JavaEar 专注于收集分享传播有价值的技术资料

What to use instead of $.getJSON()

If you are trying to to use jQuery, specifically in the React/Redux echosystem, what library should take it's place for simple rest calls? What are developers using instead of $.getJSON or $.postJSON.

Is there something commonly used that works like node's http module?

2个回答

    最佳答案
  1. My favourite library for this is axios. I find the api to be the clearest and it is very similar to the jQuery style.

    Although the fetch api is a huge improvement I don't like sending something to the server and calling it 'fetch'.

    As usual with the JS ecosystem there are hundreds of options xhr on npm so I'd recommend picking one you like the look of or has been recommended by someone you trust. @Ben's recommendations look great.

  2. 参考答案2