updated docs for http.request
This commit is contained in:
parent
fec318c2a4
commit
ed117e19c2
1 changed files with 19 additions and 17 deletions
|
@ -4765,24 +4765,26 @@ main thread of execution.
|
||||||
|
|
||||||
The following example illustrates how to use http.request to make a request to a JSON web service and evaluate its response...
|
The following example illustrates how to use http.request to make a request to a JSON web service and evaluate its response...
|
||||||
|
|
||||||
|
```javascript
|
||||||
var jsResponse;
|
var jsResponse;
|
||||||
var http = require('./http/request');
|
var http = require('request');
|
||||||
http.request("http://scriptcraftjs.org/sample.json",function(responseCode, responseBody){
|
http.request('http://scriptcraftjs.org/sample.json',function(responseCode, responseBody){
|
||||||
jsResponse = eval("(" + responseBody + ")");
|
jsResponse = JSON.parse( responseBody );
|
||||||
});
|
});
|
||||||
|
```
|
||||||
|
The following example illustrates a more complex use-case POSTing parameters to a CGI process on a server...
|
||||||
|
|
||||||
... The following example illustrates a more complex use-case POSTing parameters to a CGI process on a server...
|
```javascript
|
||||||
|
var http = require('http');
|
||||||
var http = require('./http/request');
|
http.request( {
|
||||||
http.request(
|
|
||||||
{
|
|
||||||
url: 'http://pixenate.com/pixenate/pxn8.pl',
|
url: 'http://pixenate.com/pixenate/pxn8.pl',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
params: {script: '[]'}
|
params: {script: '[]'}
|
||||||
},
|
},
|
||||||
function( responseCode, responseBody ) {
|
function( responseCode, responseBody ) {
|
||||||
var jsObj = eval('(' + responseBody + ')');
|
var jsObj = JSON.parse( responseBody );
|
||||||
});
|
});
|
||||||
|
```
|
||||||
|
|
||||||
## sc-mqtt module
|
## sc-mqtt module
|
||||||
|
|
||||||
|
|
Reference in a new issue