Skip to content

Commit 0220d13

Browse files
author
Vladimir Enchev
committed
readme updated
1 parent de2bf37 commit 0220d13

File tree

2 files changed

+4
-59
lines changed

2 files changed

+4
-59
lines changed

Tests/http-tests.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,8 @@ export var test_request_responseContentShouldBeDefined = function () {
219219
// ### Get response content
220220
// ``` JavaScript
221221
http.request({ url: "http://httpbin.org/get", method: "GET" }).then(function (response) {
222-
//// Argument (response) is HttpContent!
222+
//// Argument (response) is HttpResponse!
223+
//// Content property of the response is HttpContent!
223224
var str = response.content.toString();
224225
var obj = response.content.toJSON();
225226
var img = response.content.toImage();

http/Readme.md

Lines changed: 2 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -23,62 +23,6 @@
2323
toJSON: () => any;
2424
toImage: () => image_module.Image;
2525
}
26+
```
2627

27-
// GET request
28-
http.request({
29-
url: "http://ip.jsontest.com/",
30-
method: "GET",
31-
headers: { "Content-Type" : "application/json" }
32-
}).then(function (r) {
33-
var status = r.statusCode;
34-
35-
for (var header in r.headers) {
36-
//
37-
}
38-
39-
var result = r.content.toJSON();
40-
}).fail(function (e) { console.log(e) });
41-
42-
// POST request
43-
http.request({
44-
url: "http://posttestserver.com/post.php?dump&html&dir=test",
45-
method: "POST",
46-
headers: { "Content-Type" : "application/x-www-form-urlencoded" },
47-
content: "MyVariableOne=ValueOne&MyVariableTwo=ValueTwo"
48-
}).then(function (r) {
49-
var status = r.statusCode;
50-
51-
for (var header in r.headers) {
52-
//
53-
}
54-
55-
var result = r.content.toString();
56-
}).fail(function (e) { console.log(e) });
57-
58-
// PUT request
59-
var data = YOUR_IMAGE_DATA;
60-
http.request({
61-
url: "http://httpbin.org/put",
62-
method: "PUT",
63-
headers: {
64-
"Content-Type": "image/jpg",
65-
"Content-Length": data.length() + ""
66-
},
67-
content: data
68-
}).then(function (r) {
69-
console.log(r.content.toString())
70-
}).fail(function (e) { console.log(e) });
71-
72-
http.getString("http://www.reddit.com/").then(function(result) {
73-
// Result is string!
74-
}).fail(function(e) { console.log(e); });
75-
76-
http.getJSON("http://www.reddit.com/r/aww.json?limit=10").then(function(result) {
77-
// Result is JSON!
78-
}).fail(function(e) { console.log(e); });
79-
80-
http.getImage("http://www.google.com/images/errors/logo_sm_2.png").then(function(result) {
81-
// Result is tk.ui.Image!
82-
}).fail(function(e) { console.log(e); });
83-
84-
```
28+
More info: https://github.com/telerik/xPlatCore/blob/master/Documentation/Snippets/http.md

0 commit comments

Comments
 (0)