config.service.ts 1.35 KB
import { Injectable } from '@angular/core';
import {HttpClient} from "@angular/common/http";
import {Observable} from "rxjs";

@Injectable({
  providedIn: 'root'
})
export class ConfigService {

  configUrl = 'proxy.conf.json';

  constructor( private http: HttpClient ) { }

  getConfig() {
    return this.http.get(this.configUrl)
      .pipe(


      );
  }


  showConfig() {
    this.getConfig()
      .subscribe((data) => {
        console.log('data:', data);

      });
  }


  test(data) {

    // return new Promise<any> {
    //   return new Promise((resolve, reject) => {
    //     this.http.get(url).subscribe((res) => {
    //       resolve(res);
    //     }, reject);
    //   });
    //
    return this.get('/api/login');
    // return this.http.post('/login', data);
  }


  get(url: string): Promise<any> {
    return new Promise((resolve, reject) => {
      this.http.get(url).subscribe((res) => {
        resolve(res);
      }, reject);
    });
  }

  // login(user): Observable<any> {
  //
  //
  //   return this.http.post('/login', user).pipe(
  //     tap((data => {
  //       console.log('login', data)
  //       localStorage.setItem('token', _.get(data, 'token'));
  //       delete data['token'];
  //       localStorage.setItem('info', JSON.stringify(data));
  //       this.getInfoPromise = this.load('/user/getInfo');
  //     }))
  //   );
  // }
}