Make synchronous web requests with the request module. This is derived from the sync-request module.
npm install requestsync
request(options)
e.g.
var request = require('requestsync');
var options = {
method: 'GET',
url: 'http://example.com'
};
var res = request(options);
console.log(res.body);
Options:
For a list of options, please see the options section for the request module.
Returns:
An object containing the following:
err
- an error when applicableresp
- a serialized copy of a http.IncomingMessage object which will have missing functions and what notbody
- the response body
Internally, this uses a separate worker process that is run using either childProcess.spawnSync if available, or falling back to spawn-sync if not. The fallback will attempt to install a native module for synchronous execution, and fall back to doing busy waiting for a file to exist. All this ultimately means that the module is totally cross platform and does not require native code compilation support.
The worker then makes the actual request using request so this has almost exactly the same API as that.
- Implement more of request module's convenience methods
- Thorough testing of all the request options to verify everything is working between the parent and child process
MIT