mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
net readme updated
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
Sample code:
|
||||
```js
|
||||
var http = require("net").http;
|
||||
var http = require("net");
|
||||
|
||||
http.getString("http://www.reddit.com/").then(function(result) {
|
||||
// Result is string!
|
||||
@@ -14,4 +14,16 @@
|
||||
// Result is tk.ui.Image!
|
||||
}).fail(function(e) { console.log("Error:" + e.message); });
|
||||
|
||||
http.request({ url: "http://www.reddit.com/r/aww.json?limit=10", method: "GET" }).then(function(r) {
|
||||
console.log("Headers count:" + r.headers.length);
|
||||
|
||||
for (var i = 0, l = r.headers.length; i < l; i++) {
|
||||
var header = r.headers[i];
|
||||
console.log(header.name + ":" + header.value);
|
||||
}
|
||||
|
||||
log("Content:" + r.content.toString()); // You can use also toJSON() and toImage() to convert the content.
|
||||
|
||||
}).fail(function(e) { console.log("Error:" + e.message); });
|
||||
|
||||
```
|
||||
Reference in New Issue
Block a user