本文整理汇总了TypeScript中aurelia-http-client.HttpClient.createRequest方法的典型用法代码示例。如果您正苦于以下问题:TypeScript HttpClient.createRequest方法的具体用法?TypeScript HttpClient.createRequest怎么用?TypeScript HttpClient.createRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类aurelia-http-client.HttpClient
的用法示例。
在下文中一共展示了HttpClient.createRequest方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: getMicrosoftLoginUrl
public getMicrosoftLoginUrl(redirectUrl: string) : Promise<string> {
return this.httpClient
.createRequest(`Authentication/Login/Microsoft/Url?redirectUrl=${encodeURIComponent(redirectUrl)}`)
.asGet()
.send()
.then(response => response.content.url)
.catch(response => Promise.reject(response.content.message));
}
示例2: getSummoners
public getSummoners(token: JsonWebTokenModel): Promise<Summoner[]> {
return this.httpClient
.createRequest("Summoners")
.asGet()
.withHeader("Authorization", `Bearer ${token.token}`)
.send()
.then(response => response.content)
.catch(response => Promise.reject(response.content.message));
}
示例3: sendRequest
private sendRequest(url: string): Promise<any[]> {
return this.http.createRequest(url).asGet().send().then(
data => {
if (data.statusCode === 200) {
var obj: any = JSON.parse(data.response);
console.log(obj.value);
return obj.value;
}
return data;
});
}
示例4: loginFacebook
public loginFacebook(code: string, redirectUrl: string) : Promise<JsonWebTokenModel> {
let content = {
code: code,
redirectUrl: redirectUrl,
};
return this.httpClient
.createRequest("Authentication/Login/Facebook")
.asPost()
.withContent(content)
.send()
.then(response => response.content)
.catch(response => Promise.reject(response.content.message));
}
示例5: loginLogbook
public loginLogbook(emailAddress: string, password: string) : Promise<JsonWebTokenModel> {
let body = {
emailAddress: emailAddress,
passwordSHA256Hash: crypto.SHA256(password).toString(crypto.enc.Base64),
};
return this.httpClient
.createRequest("Authentication/Login/Logbook")
.asPost()
.withContent(body)
.send()
.then(response => response.content)
.catch(response => Promise.reject(response.content.message));
}
示例6: loginTwitter
public loginTwitter(oauthVerifier: string, payload: string) : Promise<JsonWebTokenModel> {
let content = {
oauthVerifier: oauthVerifier,
payload: payload,
};
return this.httpClient
.createRequest("Authentication/Login/Twitter")
.asPost()
.withContent(content)
.send()
.then(response => response.content)
.catch(response => Promise.reject(response.content.message));
}
示例7: deleteSummoner
public deleteSummoner(region: string, summonerId: number, token: JsonWebTokenModel): Promise<Summoner[]> {
let body = {
region: region,
summonerId: summonerId,
};
return this.httpClient
.createRequest("Summoners")
.asDelete()
.withHeader("Authorization", `Bearer ${token.token}`)
.withContent(body)
.send()
.then(response => response.content)
.catch(response => Promise.reject(response.content.message));
}
示例8: register
public register(emailAddress: string, password: string, language: string) : Promise<void> {
let body = {
emailAddress: emailAddress,
passwordSHA256Hash: crypto.SHA256(password).toString(crypto.enc.Base64),
preferredLanguage: language,
};
return this.httpClient
.createRequest("Authentication/Register")
.asPost()
.withContent(body)
.send()
.then(response => null)
.catch(response => Promise.reject(response.content.message));
}
示例9: Promise
return new Promise((resolve) => {
let requestPromise = this.httpClient.createRequest(this.api.update)
.withContent(this.serializeModelData(models))
.send();
requestPromise.then(response => {
resolve({
type: 'delete',
success: true,
data: this.getReader().read(response.content).data
});
});
requestPromise.catch(() => {
resolve({
type: 'delete',
success: false
});
});
});
示例10: reportPost
reportPost(id: number) {
this.ea.publish(new ApiStatus('Reporting Post', { status: 'info' }));
this.isRequesting = true;
return this.http.createRequest(`https://api.app.net/posts/${id}/report`)
.asPost()
.withHeader('Authorization', 'Bearer ' + this.state.token)
.withHeader('Content-Type', 'application/json')
.send()
.then((response: any) => {
this.meta = response.content.meta;
this.isRequesting = false;
this.ea.publish(new ApiStatus('Post Reported', { status: 'success' }));
return response.content.data;
}).catch((err: any) => {
this.isRequesting = false;
this.ea.publish(new ApiStatus('Unable to report post', { status: 'error' }));
return {};
});
}