本文整理匯總了TypeScript中tns-core-modules/http.getString函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript getString函數的具體用法?TypeScript getString怎麽用?TypeScript getString使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了getString函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: function
export var test_getString_fail = function (done) {
var result;
var completed: boolean;
var isReady = function () { return completed; }
http.getString({ url: "hgfttp://httpbin.org/get", method: "GET", timeout: 2000 }).catch(function (e) {
completed = true;
result = e;
done(null)
});
};
示例2: performGet
function performGet() {
console.log("Getting CSS");
http.getString("http://192.168.54.36:8080/test.css").then(
function (r) {
console.log("Applying CSS");
page.css = r;
timer.setTimeout(performGet, 1000);
},
function (e) {
console.log("Error: " + e);
timer.setTimeout(performGet, 1000);
});
}
示例3: function
export var test_getString = function (done: (err: Error, res?: string) => void) {
var result;
// >> http-get-string
http.getString("https://httpbin.org/get").then(function (r) {
//// Argument (r) is string!
// >> (hide)
result = r;
done(null);
// << (hide)
}, function (e) {
//// Argument (e) is Error!
// >> (hide)
done(e);
// << (hide)
});
// << http-get-string
};
示例4: require
require("globals");
import * as http from "tns-core-modules/http";
declare var postMessage: any;
http.getString("https://httpbin.org/get").then(function (r) {
postMessage(r);
}, function (e) {
throw e;
});