本文整理汇总了TypeScript中xhr-request.default方法的典型用法代码示例。如果您正苦于以下问题:TypeScript xhr-request.default方法的具体用法?TypeScript xhr-request.default怎么用?TypeScript xhr-request.default使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xhr-request
的用法示例。
在下文中一共展示了xhr-request.default方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: callQuery
callQuery(query: string, callback: (error?: Error, json?: any) => void) {
var url = `${appInsightsUri}/${this.appId}/query`;
try {
request(
url,
{
method: 'POST',
json: true,
headers: {
'x-api-key': this.apiKey
},
body: { query }
},
(error: Error, json: any) => {
if (error) {
callback(error);
}
callback(null, json);
}
);
} catch (ex) {
callback(ex);
}
}
示例2: dispatcher
return (dispatcher: (json: any) => void) => {
// Replace both 'id' and 'url' with the requested id from the user
const idRegExPattern = /id: \".*\",/i;
const urlRegExPatternt = /url: \".*\",/i;
const updatedContent =
content.replace(idRegExPattern, 'id: \"' + dashboardId + '\",')
.replace(urlRegExPatternt, 'url: \"' + dashboardId + '\",');
request(
'/api/dashboards/' + dashboardId,
{
method: 'PUT',
json: true,
body: { script: updatedContent }
},
(error: any, json: any) => {
if (error || (json && json.errors)) {
return this.failure(error || json.errors);
}
// redirect to the newly imported dashboard
window.location.replace('dashboard/' + dashboardId);
return dispatcher(json);
}
);
};
示例3: request
(setupError: any, setupJson: any) => {
if (setupError) {
return this.failure(setupError);
}
return request('/auth/init',
(authError: any, authJson: any) => {
if (authError) {
return this.failure(authError);
}
let toast: IToast = { text: 'Setup was saved successfully.' };
ToastActions.addToast(toast);
try {
if (successCallback) {
successCallback();
}
} catch (e) { }
return dispatcher(authJson);
}
);
}
示例4: dispatch
return (dispatch) => {
request('/api/dashboards/' + dashboardId + '?format=raw', {}, function (err: any, data: any) {
if (err) {
throw err;
}
return dispatch( data );
});
};
示例5: dispatcher
return (dispatcher: (account: IDictionary) => void) => {
request('/auth/account', { json: true }, (error: any, result: any) => {
if (error || result && result.error) {
return this.failure(error || result && result.error);
}
return dispatcher({ account: result.account });
}
);
};
示例6: request
return (dispatcher: (result: { template: IDashboardConfig }) => void) => {
let script = utils.objectToString(template);
script = '/// <reference path="../../../client/@types/types.d.ts"/>\n' +
'import * as _ from \'lodash\';\n\n' +
'export const config: IDashboardConfig = /*return*/ ' + script;
return request(
'/api/templates/' + template.id,
{
method: 'PUT',
json: true,
body: { script: script }
},
(error: any, json: any) => {
if (error || (json && json.errors)) {
return this.failure(error || json.errors);
}
return dispatcher(json);
}
);
};