本文整理汇总了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;
});