admin管理员组

文章数量:1295722

I need a request module that works both in the Node.js server and in the client, when bundled with Webpack.

My requirements are really basic. I just need to do some HTTP Ajax requests, like get and post. Automatic JSON parsing would be awesome.

I'm taking a look at Request, which seems solid by the number of mits and downloads, but the website doesn't mention whether it works while bundled in the browser.

Any suggestion?

I need a request module that works both in the Node.js server and in the client, when bundled with Webpack.

My requirements are really basic. I just need to do some HTTP Ajax requests, like get and post. Automatic JSON parsing would be awesome.

I'm taking a look at Request, which seems solid by the number of mits and downloads, but the website doesn't mention whether it works while bundled in the browser.

Any suggestion?

Share asked Jul 30, 2015 at 1:04 Andre PenaAndre Pena 59.4k53 gold badges209 silver badges257 bronze badges 2
  • 1 Try request, and get back to us. Should be fine. – azium Commented Jul 30, 2015 at 1:08
  • I tried request, didn't work for me. Needed lots of other dependencies. Maybe I'm doing something wrong though. Did you get it working? – willem Commented Jan 4, 2016 at 13:40
Add a ment  | 

2 Answers 2

Reset to default 7

I use axios

Promise based HTTP client for the browser and node.js

Features

  • Make XMLHttpRequests from the browser
  • Make http requests from node.js
  • Supports the Promise API
  • Intercept request and response
  • Transform request and response data
  • Cancel requests
  • Automatic transforms for JSON data
  • Client side support for protecting against XSRF

Try SuperAgent

SuperAgent is a small progressive client-side HTTP request library, and Node.js module with the same API


Works with browserify and should work with webpack

本文标签: