import {Component, OnInit} from '@angular/core';
import {RequestService} from './request.service';
import Promise from 'bluebird';

@Component({
  selector: 'app-request',
  templateUrl: './request.component.html',
  styleUrls: ['./request.component.css']
})
export class RequestComponent implements OnInit {

  feature: String;

  features: String;

  email: String;

  constructor(private requestService: RequestService) {
  }


  ngOnInit() {
    this.get();
  }

  save() {
    var that = this;
    this.requestService.postFeature(this.feature)
      .subscribe(
        () => {
          this.get().then(() => {
            that.feature = '';
          });
        },
        (error) => console.log(error)
      );
  }

  
() {
    var that = this;
    return new Promise(function (resolve, reject) {
      that.requestService.fetchFeatures()
        .subscribe(
          (response) => {
            that.features = response.text();
            resolve();
          },
          (error) => {
            reject(error);
          }
        );
    });
  }
}

get