本文整理汇总了TypeScript中aurelia-http-client.HttpClient.configure方法的典型用法代码示例。如果您正苦于以下问题:TypeScript HttpClient.configure方法的具体用法?TypeScript HttpClient.configure怎么用?TypeScript HttpClient.configure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类aurelia-http-client.HttpClient
的用法示例。
在下文中一共展示了HttpClient.configure方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: createPost
createPost(text: string, options: any) {
this.ea.publish(new ApiStatus('Creating Post', { status: 'info' }));
var jsonText = {
text: text,
entities: {
parse_links: true,
parse_markdown_links: true
},
reply_to: 0
};
if (options.reply_to) { jsonText.reply_to = options.reply_to; }
this.isRequesting = true;
return this.http.configure((x: any) => {
x.withHeader('Authorization', 'Bearer ' + this.state.token);
x.withHeader('Content-Type', 'application/json');
}).post(`https://api.app.net/posts`, jsonText)
.then((response: any) => {
this.meta = response.content.meta;
this.isRequesting = false;
this.ea.publish(new ApiStatus('Post Created', { status: 'success' }));
return response.content.data;
}).catch((err: any) => {
this.isRequesting = false;
this.ea.publish(new ApiStatus('Unable to post', { status: 'error' }));
return {};
});
}
示例2: textProcess
textProcess(text: string) {
let jsonText = { text: text };
this.isRequesting = true;
return this.http.configure((x: any) => {
x.withHeader('Authorization', 'Bearer ' + this.state.token);
x.withHeader('Content-Type', 'application/json');
}).post(`https://api.app.net/text/process?parse_links=true&parse_markdown_links=true`, jsonText)
.then((response: any) => {
this.meta = response.content.meta;
this.isRequesting = false;
return response.content.data;
}).catch((err: any) => {
this.isRequesting = false;
return nouser.data;
});
}
示例3: setMarker
setMarker(id: number) {
var jsonText = {
id: id,
name: 'unified'
};
this.isRequesting = true;
return this.http.configure((x: any) => {
x.withHeader('Authorization', 'Bearer ' + this.state.token);
x.withHeader('Content-Type', 'application/json');
}).post(`https://api.app.net/posts/marker`, jsonText)
.then((response: any) => {
this.meta = response.content.meta;
this.isRequesting = false;
this.ea.publish(new ApiStatus('Marker Set', { status: 'success' }));
return response.content.data;
}).catch((err: any) => {
this.isRequesting = false;
this.ea.publish(new ApiStatus('Unable to set marker', { status: 'error' }));
return {};
});
}
示例4: constructor
public constructor(private httpClient: HttpClient) {
this.httpClient.configure(f => f
.withBaseUrl(config.webServiceUri)
.withHeader("Content-Type", "application/json"));
}
示例5: constructor
constructor(private http: HttpClient) {
this.http = http.configure((x: any) => {
x.withBaseUrl('https://api.nice.social/');
});
}
示例6: configure
export function configure(frameworkConfiguration: FrameworkConfiguration, pluginConfiguration: Function) {
let container: Container = frameworkConfiguration.container;
let httpClient: HttpClient = container.get(HttpClient);
httpClient.configure(x => x.withInterceptor(new JsonMessageContentInterceptor()));
}
示例7: constructor
constructor(protected http: HttpClient) {
this.http.configure(cfg =>
cfg.withHeader("Accept", "application/json")
.withHeader("Content-Type", "application/json"));
}
示例8: constructor
constructor(private httpClient: HttpClient) {
console.log('helllooooo');
this.httpClient.configure(config => {
config.withHeader('Accept', 'application/json');
});
}