Make synchronous web requests with the request module. This is derived from the sync-request module.
npm install requestsync
var request = ;var options =method: 'GET'url: '';var res = ;console;
For a list of options, please see the options section for the request module.
An object containing the following:
err- an error when applicable
resp- a serialized copy of a http.IncomingMessage object which will have missing functions and what not
body- the response body
How is this possible?
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