當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript aurelia-fetch-client.json函數代碼示例

本文整理匯總了TypeScript中aurelia-fetch-client.json函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript json函數的具體用法?TypeScript json怎麽用?TypeScript json使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了json函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: create

 create(entity:Pessoa){
     return this.httpClient.fetch('pessoas',{
         method: 'post',
         redirect: 'follow',
         body: json(entity)
     });
 }
開發者ID:Diego-Rocha,項目名稱:stack-sample,代碼行數:7,代碼來源:pessoa-service.ts

示例2: 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

示例3: json

 return new Promise<Tweet>((resolve, reject)=> {
     this.httpClient.fetch(BASE_URL + TWEET_URL, {
         method: 'post',
         headers: {
             [Const.TOKEN_HEADER]: this.authToken
         },
         body: json(tweet)
     })
         .then(response => {
             let data = response.json();
             if (response.ok) {
                 data.then((data:Tweet) => {
                     this.postHelper.getCurrentUserPostData(data);
                     resolve(data)
                 });
             }
             else {
                 data.then(res=> {
                     if (response.status == 400) {
                         console.log(res.errors[0].defaultMessage);
                         reject(res.errors[0].defaultMessage);
                     }else {
                         reject(res.message)
                     }
                 })
             }
         });
 });
開發者ID:m4riusz,項目名稱:Twitter,代碼行數:28,代碼來源:tweetService.ts

示例4: save

 save(customer: Customer): Promise<Customer> {
   if (customer.id) {
     return this.http.fetch(`${baseUrl}/${customer.id}`, {
       method: 'put',
       body: json(customer)
     })
     .then(response => response.json());
   }
   else {
     return this.http.fetch(`${baseUrl}`, {
       method: 'post',
       body: json(customer)
     })
     .then(response => response.json());
   }
 }
開發者ID:ghiscoding,項目名稱:Realtime-TODO-Aurelia-RethinkDB,代碼行數:16,代碼來源:customerData.ts

示例5: json

        return new Promise<string>((resolve, reject) => {
            this.httpClient
                .fetch(BASE_URL + REGISTER, {
                    method: 'post',
                    headers: {
                        "Content-Type": "application/json"
                    },
                    body: json({
                        "username": username,
                        "password": password,
                        "email": email,
                        "gender": gender
                    })
                })
                .then(response => {
                        if (response.ok) {
                            resolve('Account has been created');
                        } else {
                            response.json().then(error => {
                                if (response.status == 400) {
                                    reject(error.errors[0].defaultMessage);
                                } else {
                                    reject(error.message);
                                }
                            });
                        }

                    }
                )
        });
開發者ID:m4riusz,項目名稱:Twitter,代碼行數:30,代碼來源:authService.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: updatePump

 updatePump(pump: SumpPump) {
     this.fetchClient.fetch('pumps/' + pump.pumpId, {
             method: 'put',
             body: json(pump)
     })
     .then()
 }
開發者ID:NickSchweitzer,項目名稱:SumpPumpMonitor,代碼行數:7,代碼來源:api.ts

示例8: updateUserState

 async updateUserState(state: UpdateUserState): Promise<UserState> {
   const resp = await this.http.fetch('api/state', {
     method: 'PATCH',
     body: json(state)
   });
   const data = await resp.json();
   return this.toUserState(data);
 }
開發者ID:sebthieti,項目名稱:jogplayer-online,代碼行數:8,代碼來源:userState.repository.ts

示例9: updatePlaylist

 async updatePlaylist(playlistIndex: number, playlist: UpsertPlaylist): Promise<Playlist> {
   const resp = await this.http.fetch(`api/playlists/${playlistIndex}`, {
     method: 'PATCH',
     body: json(playlist)
   });
   const data = await resp.json();
   return this.toPlaylist(data);
 }
開發者ID:sebthieti,項目名稱:jogplayer-online,代碼行數:8,代碼來源:playlist.repository.ts

示例10: saveComment

 saveComment(comment: Comment): Promise<Comment> {
     return this.http.fetch(`${this.apiRoot}comments`, {
         method: "POST",
         body: json(comment),
     })
         .then(response => response.json())
         .then(comment => comment as Comment);
 }
開發者ID:Costo,項目名稱:aurelia-training,代碼行數:8,代碼來源:api.ts


注:本文中的aurelia-fetch-client.json函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。