当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript HttpClient.fetch方法代码示例

本文整理汇总了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)
             });
         }
     }
 }
开发者ID:Lesslimit,项目名称:MeeToo,代码行数:14,代码来源:dataService.ts

示例2: markAllCompleted

 markAllCompleted(flag: boolean): Promise<Todo[]> {
   return this.http.fetch(`${baseUrl}/mark-all-completed/${flag}`, {
     method: 'post',
     body: null
   })
   .then(response => response.json());
 }
开发者ID:ghiscoding,项目名称:Realtime-TODO-Aurelia-RethinkDB,代码行数:7,代码来源:todoData.ts

示例3: purgeArchiveItems

 purgeArchiveItems(): Promise<Todo[]> {
   return this.http.fetch(`${baseUrl}/purge-archived-items`, {
     method: 'post',
     body: null
   })
   .then(response => response.json());
 }
开发者ID:ghiscoding,项目名称:Realtime-TODO-Aurelia-RethinkDB,代码行数:7,代码来源:todoData.ts

示例4: archiveAllCompleted

 archiveAllCompleted(): Promise<Todo[]> {
   return this.http.fetch(`${baseUrl}/archive-all-completed`, {
     method: 'post',
     body: null
   })
   .then(response => response.json());
 }
开发者ID:ghiscoding,项目名称:Realtime-TODO-Aurelia-RethinkDB,代码行数:7,代码来源:todoData.ts

示例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());
   }
 }
开发者ID:ghiscoding,项目名称:Realtime-TODO-Aurelia-RethinkDB,代码行数:16,代码来源:todoData.ts

示例6: create

 create(todo: Todo): Promise<Todo> {
   return this.http.fetch(`${baseUrl}`, {
     method: 'post',
     body: json(todo)
   })
   .then(response => response.json());
 }
开发者ID:ghiscoding,项目名称:Realtime-TODO-Aurelia-RethinkDB,代码行数:7,代码来源:todoData.ts

示例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();
				});
		}
	}
开发者ID:ishyfishyy,项目名称:aurelia-contacts,代码行数:29,代码来源:store.ts

示例8: constructor

 constructor(http: HttpClient) {
     http.fetch('api/SampleData/WeatherForecasts')
         .then(result => result.json() as Promise<WeatherForecast[]>)
         .then(data => {
             this.forecasts = data;
         });
 }
开发者ID:couchbaselabs,项目名称:blog-source-code,代码行数:7,代码来源:fetchdata.ts

示例9: updatePump

 updatePump(pump: SumpPump) {
     this.fetchClient.fetch('pumps/' + pump.pumpId, {
             method: 'put',
             body: json(pump)
     })
     .then()
 }
开发者ID:NickSchweitzer,项目名称:SumpPumpMonitor,代码行数:7,代码来源:api.ts

示例10: getPosts

 getPosts(): Promise<IPost[]>{
   return this._http.fetch('../../../../data/posts.json').then(response => {
     return response.text();
   }).then(data => {
     return JSON.parse(data);
   });
 }
开发者ID:avizcaino,项目名称:avizcaino.github.io,代码行数:7,代码来源:blog-service.ts


注:本文中的aurelia-fetch-client.HttpClient.fetch方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。