我正在为我的授权服务器和受保护的api设置aurelia-auth并配置端点:
aurelia.use.plugin('aurelia-api', configure => {
configure
.registerEndpoint('auth', 'http://localhost:5000/')
.registerEndpoint('api', 'http://localhost:5006')}
当我想获取数据时,我将AuthService注入我的模块,然后调用
this.authService.config.client.client.fetch('StaticData/offices')
但这会调用auth
端点而不是api
端点,如何告诉获取客户端使用非默认端点?
答案 0 :(得分:0)
我正朝着错误的道路前进,您使用aurelia-api
之外的配置对象来获取您可以调用的端点:
import { inject } from 'aurelia-framework';
import { Config } from 'aurelia-api'
@inject (Config)
export class Locations {
constructor (private apiEndpointConfig: Config)
{}
dataItems;
hasItems: boolean;
created(){
var api = this.apiEndpointConfig.getEndpoint('api');
api.client.fetch('StaticData/offices')
.then(response=>response.json())
.then(response=>
{
this.dataItems=response;
this.hasItems=true;
});
}
}