mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-17 21:01:34 +08:00
Merge branch 'ErjanGavalji/add-post-json-sample'
This commit is contained in:
@ -364,6 +364,9 @@ export var test_request_NonStringHeadersSentAndReceivedProperly = function (done
|
|||||||
};
|
};
|
||||||
|
|
||||||
export var test_request_jsonAsContentSentAndReceivedProperly = function (done) {
|
export var test_request_jsonAsContentSentAndReceivedProperly = function (done) {
|
||||||
|
// <snippet module="http" title="http">
|
||||||
|
// ### Post JSON
|
||||||
|
// ``` JavaScript
|
||||||
var result;
|
var result;
|
||||||
|
|
||||||
http.request({
|
http.request({
|
||||||
@ -371,17 +374,27 @@ export var test_request_jsonAsContentSentAndReceivedProperly = function (done) {
|
|||||||
headers: { "Content-Type": "application/json" },
|
headers: { "Content-Type": "application/json" },
|
||||||
content: JSON.stringify({ MyVariableOne: "ValueOne", MyVariableTwo: "ValueTwo" })
|
content: JSON.stringify({ MyVariableOne: "ValueOne", MyVariableTwo: "ValueTwo" })
|
||||||
}).then(function (response) {
|
}).then(function (response) {
|
||||||
|
// result = response.content.toJSON();
|
||||||
|
// <hide>
|
||||||
result = response.content.toJSON();
|
result = response.content.toJSON();
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
TKUnit.assert(result["json"]["MyVariableOne"] === "ValueOne" && result["json"]["MyVariableTwo"] === "ValueTwo", "Content not sent/received properly!");
|
TKUnit.assert(result["json"]["MyVariableOne"] === "ValueOne" && result["json"]["MyVariableTwo"] === "ValueTwo", "Content not sent/received properly!");
|
||||||
done(null);
|
done(null);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
done(err);
|
done(err);
|
||||||
}
|
}
|
||||||
|
// </hide>
|
||||||
|
// console.log(result);
|
||||||
}, function (e) {
|
}, function (e) {
|
||||||
|
// <hide>
|
||||||
done(e);
|
done(e);
|
||||||
|
// </hide>
|
||||||
|
// console.log("Error occurred " + e);
|
||||||
});
|
});
|
||||||
|
// ```
|
||||||
|
// </snippet>
|
||||||
};
|
};
|
||||||
|
|
||||||
export var test_getString_FromVariousUrls_ShouldWorkProperly = function (done) {
|
export var test_getString_FromVariousUrls_ShouldWorkProperly = function (done) {
|
||||||
|
Reference in New Issue
Block a user