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...
|
||||||
|
|
||||||
var jsResponse;
|
```javascript
|
||||||
var http = require('./http/request');
|
var jsResponse;
|
||||||
http.request("http://scriptcraftjs.org/sample.json",function(responseCode, responseBody){
|
var http = require('request');
|
||||||
jsResponse = eval("(" + responseBody + ")");
|
http.request('http://scriptcraftjs.org/sample.json',function(responseCode, 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',
|
||||||
{
|
method: 'POST',
|
||||||
url: 'http://pixenate.com/pixenate/pxn8.pl',
|
params: {script: '[]'}
|
||||||
method: 'POST',
|
},
|
||||||
params: {script: '[]'}
|
function( responseCode, responseBody ) {
|
||||||
},
|
var jsObj = JSON.parse( responseBody );
|
||||||
function( responseCode, responseBody ) {
|
});
|
||||||
var jsObj = eval('(' + responseBody + ')');
|
```
|
||||||
});
|
|
||||||
|
|
||||||
## sc-mqtt module
|
## sc-mqtt module
|
||||||
|
|
||||||
|
|
Reference in a new issue