本文整理汇总了TypeScript中aurelia-fetch-client.HttpClient.fetch方法的典型用法代码示例。如果您正苦于以下问题:TypeScript HttpClient.fetch方法的具体用法?TypeScript HttpClient.fetch怎么用?TypeScript HttpClient.fetch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类aurelia-fetch-client.HttpClient
的用法示例。
在下文中一共展示了HttpClient.fetch方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: students
static get students() {
return {
getAll() {
return httpClient.fetch('students/getAll');
},
register(user) {
return httpClient.fetch('oauth/register',
{
method: 'post',
body: json(user)
});
}
}
}
示例2: markAllCompleted
markAllCompleted(flag: boolean): Promise<Todo[]> {
return this.http.fetch(`${baseUrl}/mark-all-completed/${flag}`, {
method: 'post',
body: null
})
.then(response => response.json());
}
示例3: purgeArchiveItems
purgeArchiveItems(): Promise<Todo[]> {
return this.http.fetch(`${baseUrl}/purge-archived-items`, {
method: 'post',
body: null
})
.then(response => response.json());
}
示例4: archiveAllCompleted
archiveAllCompleted(): Promise<Todo[]> {
return this.http.fetch(`${baseUrl}/archive-all-completed`, {
method: 'post',
body: null
})
.then(response => response.json());
}
示例5: save
save(todo: Todo): Promise<Todo> {
if (todo.id) {
return this.http.fetch(`${baseUrl}/${todo.id}`, {
method: 'put',
body: json(todo)
})
.then(response => response.json());
}
else {
return this.http.fetch(`${baseUrl}`, {
method: 'post',
body: json(todo)
})
.then(response => response.json());
}
}
示例6: create
create(todo: Todo): Promise<Todo> {
return this.http.fetch(`${baseUrl}`, {
method: 'post',
body: json(todo)
})
.then(response => response.json());
}
示例7: 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();
});
}
}
示例8: constructor
constructor(http: HttpClient) {
http.fetch('api/SampleData/WeatherForecasts')
.then(result => result.json() as Promise<WeatherForecast[]>)
.then(data => {
this.forecasts = data;
});
}
示例9: updatePump
updatePump(pump: SumpPump) {
this.fetchClient.fetch('pumps/' + pump.pumpId, {
method: 'put',
body: json(pump)
})
.then()
}
示例10: getPosts
getPosts(): Promise<IPost[]>{
return this._http.fetch('../../../../data/posts.json').then(response => {
return response.text();
}).then(data => {
return JSON.parse(data);
});
}