本文整理匯總了TypeScript中src/request/xhr.default函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript default函數的具體用法?TypeScript default怎麽用?TypeScript default使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了default函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: resolve
}
resolve();
},
function () {
resolve();
}
);
});
},
'HTTP methods': {
specified(this: any) {
if (!echoServerAvailable) {
this.skip('No echo server available');
}
return xhrRequest('/__echo/foo.json', { method: 'get' })
.then(function (response: any) {
assert.strictEqual(response.requestOptions.method, 'get');
});
},
'default'(this: any) {
if (!echoServerAvailable) {
this.skip('No echo server available');
}
return xhrRequest('/__echo/foo.json')
.then(function (response: any) {
assert.strictEqual(response.requestOptions.method, 'GET');
});
},
示例2: requestResponseType
function requestResponseType(responseType?: string, options?: any) {
if (options) {
return xhrRequest('/__echo/xhr' + (responseType ? '?responseType=' + responseType : ''), options);
}
else {
return xhrRequest('/__echo/xhr' + (responseType ? '?responseType=' + responseType : ''));
}
}
示例3:
setTimeout(function () {
xhrRequest('/__echo/xhr', {
cacheBust: true,
query: {
foo: 'bar'
}
}).then(resolve, reject);
}, 5);
示例4: xhrRequest
}).then(function (response: any) {
cacheBustStringA = response.url.split('?')[1];
assert.ok(cacheBustStringA);
assert.isFalse(isNaN(Number(cacheBustStringA)));
return xhrRequest('/__echo/xhr', {
cacheBust: true
});
}).then(function (response: any) {
示例5: Promise
return new Promise(function (resolve, reject) {
xhrRequest('/__echo/', {
method: 'get',
timeout: 10000
}).then(
function (response) {
if (response && response.statusCode === 200) {
echoServerAvailable = true;
}
resolve();
},
function () {
resolve();
}
);
});