本文整理匯總了TypeScript中core/utils/collections.buildQueryString函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript buildQueryString函數的具體用法?TypeScript buildQueryString怎麽用?TypeScript buildQueryString使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了buildQueryString函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: function
return function(data : any, callback : Function) {
var scheme = "http" + (useTLS ? "s" : "") + "://";
var url = scheme + (sender.host || sender.options.host) + sender.options.path;
var query = Collections.buildQueryString(data);
url += ("/" + 2 + "?" + query);
var xhr = Runtime.createXHR();
xhr.open("GET", url, true);
xhr.onreadystatechange = function(){
if (xhr.readyState === 4) {
let {status, responseText} = xhr;
if (status !== 200) {
Logger.debug(`TimelineSender Error: received ${status} from stats.pusher.com`);
return;
}
try {
var {host} = JSON.parse(responseText);
} catch(e) {
Logger.debug(`TimelineSenderError: invalid response ${responseText}`);
}
if (host) {
sender.host = host;
}
}
}
xhr.send();
}
示例2: send
/** Sends the actual JSONP request.
*
* @param {ScriptReceiver} receiver
*/
send(receiver : ScriptReceiver) {
if (this.request) {
return;
}
var query = Collections.buildQueryString(this.data);
var url = this.url + "/" + receiver.number + "?" + query;
this.request = Runtime.createScriptRequest(url);
this.request.send(receiver);
}
示例3: function
return function(data : any, callback : Function) {
var scheme = "http" + (useTLS ? "s" : "") + "://";
var url = scheme + (sender.host || sender.options.host) + sender.options.path;
var query = Collections.buildQueryString(data);
url += ("/" + 2 + "?" + query);
fetch(url).
then((response) => {
if (response.status !== 200) {
throw(`received ${response.status} from stats.pusher.com`)
}
return response.json();
}).then(({host})=>{
if (host) {
sender.host = host;
}
}).catch((err)=> {
Logger.debug("TimelineSender Error: ", err);
});
}