Aurelia не получает ответ json с клиентом fetch - PullRequest
0 голосов
/ 17 января 2019

Я пытаюсь использовать клиент извлечения для получения объекта json, который содержит большой массив. Я вижу обещание в консоли, которое содержит значение, но при попытке просмотреть данные из ответа это пустой объект {}. Что я делаю не так?

@inject(Router,HttpClientService)
export class GameMap {

  constructor(router,client) {
    this.client = client.client;
     firebase.auth().onAuthStateChanged((user) => {
      if (user) {
        this.user = user;
        user.getIdToken().then((idtoken) => this.client.configure(config => config.withDefaults(({headers: {'ID-TOKEN': idtoken}})))).then(() => this.requestMap());
      }
    });
  }

  requestMap() {
    this.client.fetch('game').then(response => json(response)).then((data) => console.log(data))
  }

}

HttpClientService

    export class HttpClientService {

  constructor(){
    this.client = new HttpClient();
    this.client.configure(config => {
      config
        .withBaseUrl('http://localhost:8808/')
        .withInterceptor({
          request(request) {
            console.log(request)
            console.log(`Requesting ${request.method} ${request.url}`);

            return request;
          },
          response(response) {
            console.log(`Received ${response.status} ${response.url}`);
            return response;
          }
        });
    });
  }



}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...