我正在为我的授权服务器和一个受保护的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端点调用的,如何告诉fetch客户机使用非默认端点呢?
发布于 2017-07-03 19:04:49
我走错了路,您使用aurelia-api中的configuration对象来获取一个端点,然后可以调用:
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;
});
}}
https://stackoverflow.com/questions/44829724
复制相似问题