Skip to content

Commit 97f24c0

Browse files
committed
Merge branch 'ErjanGavalji/apply-post-json-example-from-master' into release
2 parents 15c3b43 + 533330d commit 97f24c0

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

apps/tests/http-tests.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,24 +364,37 @@ export var test_request_NonStringHeadersSentAndReceivedProperly = function (done
364364
};
365365

366366
export var test_request_jsonAsContentSentAndReceivedProperly = function (done) {
367+
// <snippet module="http" title="http">
368+
// ### Post JSON
369+
// ``` JavaScript
367370
var result;
368371

369372
http.request({
370373
url: "https://httpbin.org/post", method: "POST",
371374
headers: { "Content-Type": "application/json" },
372375
content: JSON.stringify({ MyVariableOne: "ValueOne", MyVariableTwo: "ValueTwo" })
373376
}).then(function (response) {
377+
// result = response.content.toJSON();
378+
// <hide>
374379
result = response.content.toJSON();
375-
try {
380+
try
381+
{
376382
TKUnit.assert(result["json"]["MyVariableOne"] === "ValueOne" && result["json"]["MyVariableTwo"] === "ValueTwo", "Content not sent/received properly!");
377383
done(null);
378384
}
379385
catch (err) {
380386
done(err);
381387
}
388+
// </hide>
389+
// console.log(result);
382390
}, function (e) {
391+
// <hide>
383392
done(e);
393+
// </hide>
394+
// console.log("Error occurred " + e);
384395
});
396+
// ```
397+
// </snippet>
385398
};
386399

387400
export var test_getString_FromVariousUrls_ShouldWorkProperly = function (done) {
@@ -554,4 +567,4 @@ export var test_XMLHttpRequest_requestShouldBePossibleAfterAbort = function (don
554567
xhr.abort();
555568

556569
xhr.send(JSON.stringify({ MyVariableOne: "ValueOne", MyVariableTwo: "ValueTwo" }));
557-
};
570+
};

0 commit comments

Comments
 (0)