當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。