本文整理汇总了TypeScript中aurelia-fetch-client.HttpClient.configure方法的典型用法代码示例。如果您正苦于以下问题:TypeScript HttpClient.configure方法的具体用法?TypeScript HttpClient.configure怎么用?TypeScript HttpClient.configure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类aurelia-fetch-client.HttpClient
的用法示例。
在下文中一共展示了HttpClient.configure方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: constructor
constructor(private http: HttpClient) {
http.configure(config => {
config
.useStandardConfiguration()
.withBaseUrl('https://api.github.com/');
});
}
示例2: constructor
constructor(public httpClient: HttpClient,
public appState: UIApplication,
public eventAggregator: EventAggregator) {
this.appState.info(this.constructor.name, 'Initialized');
let self = this;
httpClient.configure(
config => {
config
.withBaseUrl(UIConstants.Http.BaseUrl)
//.withDefaults({})
.withInterceptor({
request(request) {
appState.info(self.constructor.name, `Requesting ${request.method} ${request.url}`);
appState.IsHttpInUse = true;
//request.url = encodeURI(request.url);
return request;
},
response(response) {
appState.info(self.constructor.name, `Response ${response.status} ${response.url}`);
appState.IsHttpInUse = false;
if (response instanceof TypeError) {
throw Error(response['message']);
}
if (response.status == 401) {
eventAggregator.publish('Unauthorized', null);
}
else if (response.status != 200) {
return response.text()
.then(resp => {
let json: any = {};
let error = 'Network Error!!';
try {
console.log(resp);
json = JSON.parse(resp);
if (json.message) error = json.message;
else if (json.error) error = json.error;
else if (response.statusText) error = response.statusText;
} catch (e) { }
if (error) throw new Error(error);
return null;
});
}
return response;
},
requestError(error) {
appState.IsHttpInUse = false;
if (error !== null) throw Error(error.message);
return error;
},
responseError(error) {
appState.IsHttpInUse = false;
if (error !== null) throw Error(error.message);
return error;
}
});
});
}
示例3: constructor
constructor(private http: HttpClient, private observerLocator: ObserverLocator) {
//localStorage.clear();
this.contacts = JSON.parse(localStorage.getItem(Constants.STORAGE_CONTACTS));
if (!this.contacts) {
http.configure(config => {
config.useStandardConfiguration().withBaseUrl('https://api.github.com/');
});
http.fetch('users')
.then(response => response.json())
.then(users => {
this.contacts = users.map((user: { id: number, login: string, avatar_url: string, type: string }) => {
let contact = new Contact();
contact.id = user.id;
contact.username = user.login;
contact.email = user.login + "@email.com";
contact.avatarUrl = user.avatar_url;
contact.description = user.type;
contact.checked = false;
return contact;
});
this.contacts = this.contacts.splice(20);
this.updateStorage();
this.applyObservers();
});
}
}
示例4: constructor
constructor(http: HttpClient) {
http.configure(config => {
config
.withBaseUrl("http://localhost:64439/api/");
});
this.http = http;
}
示例5: constructor
constructor(private httpClient: HttpClient, private oAuthProvider: IOAuthProvider)
{
this.httpClient.configure(config => {
config.withBaseUrl('http://localhost:19388/api/');
config.withDefaults({ mode: 'cors' });
});
}
示例6: constructor
constructor(private _http: HttpClient, private _eventAggregator: EventAggregator) {
_http.configure(config => {
config
.useStandardConfiguration()
.withBaseUrl('http://localhost:8080/api/');
});
};
示例7: constructor
constructor(private http: HttpClient) {
http.baseUrl = 'http://localhost:10000/';
http.configure(config => config
.withDefaults({
credentials: 'include'
})
);
}
示例8: constructor
constructor(httpClient: HttpClient) {
httpClient.configure(config => {
config
.useStandardConfiguration()
.withBaseUrl('http://localhost:8080/');
});
this.httpClient = httpClient;
}
示例9: constructor
constructor(http: HttpClient) {
http.configure(config => {
config
.withBaseUrl('http://localhost:5000/api/');
});
this.httpClient = http;
}
示例10: constructor
constructor(
private http: HttpClient,
private config: Configuration) {
http.configure(client => {
client
.useStandardConfiguration()
.withBaseUrl(config.get("rest.baseUrl").asString());
});
}