我正在创建一个使用 API 的 Aurelia Web 项目。API 以 Azure 移动服务的形式提供。我知道我需要将 X-ZUMO Auth 标头添加到请求中。但是,当我实例化我的 http 客户端时,该标头永远不会根据浏览器开发工具进入请求标头。当我在我的应用程序中运行它时,我会看到一个登录屏幕,我认为是因为 X-ZUMO 标头不是存在,因此该应用程序没有运行权限。我正在使用 gulp 运行它,它正在为我设置 Web 应用程序的本地实例。我也试过外部IP地址。
这是我的课:
import {HttpClient} from 'aurelia-http-client';
export class WebApi
{
static inject = [HttpClient];
constructor(http)
{
this.http = http;
this.baseUrl = 'https://myProject.azure-mobile.net/';
this.zumoHeader = 'X-ZUMO-APPLICATION';
this.zumoKey = 'zumoKey';
this.client = new HttpClient()
.configure(x => {
x.withBaseUrl(this.baseUrl);
x.withHeader(this.zumoHeader, this.zumoKey);
});
}
// requests will go here
testGet()
{
this.client.jsonp('api/logs?application_id=sessionID&__count=20')
.then(response =>
{
alert(response);
});
}
}