本文整理汇总了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)
});
}
示例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());
}
}
示例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)
}
})
}
});
});
示例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());
}
}
示例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);
}
});
}
}
)
});
示例6: create
create(todo: Todo): Promise<Todo> {
return this.http.fetch(`${baseUrl}`, {
method: 'post',
body: json(todo)
})
.then(response => response.json());
}
示例7: updatePump
updatePump(pump: SumpPump) {
this.fetchClient.fetch('pumps/' + pump.pumpId, {
method: 'put',
body: json(pump)
})
.then()
}
示例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);
}
示例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);
}
示例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);
}