当前位置: 首页>>代码示例>>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;未经允许,请勿转载。