使用 Aurelia Auth 时如何配置 FetchClient 以使用非默认 api

How do I configure FetchClient to use a non-default api when using Aurelia Auth

我正在为我的授权服务器和受保护的 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 端点调用的,我如何告诉获取客户端使用非默认端点?

我走错了路,你使用配置对象关闭 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;
    });
 }

}