datasets.component.ts 1.32 KB
Newer Older
cazenave's avatar
cazenave committed
1
import { Component, OnInit } from '@angular/core';
Administrator's avatar
Administrator committed
2
3
4
5
6
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { AppConfiguration } from '../AppConfiguration';
import { FileSaverService } from 'ngx-filesaver';
import { resolve } from 'url';
import { Observable } from 'rxjs';
cazenave's avatar
cazenave committed
7
8
9
10
11
12
13

@Component({
  selector: 'app-datasets',
  templateUrl: './datasets.component.html',
  styleUrls: ['./datasets.component.scss']
})
export class DatasetsComponent implements OnInit {
Administrator's avatar
Administrator committed
14
15
  result: Promise<any>;
  dataresult: any;
cazenave's avatar
cazenave committed
16

Administrator's avatar
Administrator committed
17
18
19
20
21
  constructor(
    private appConfig: AppConfiguration,
    private http: HttpClient,
    private _FileSaverService: FileSaverService,
  ) { }
cazenave's avatar
cazenave committed
22
23

  ngOnInit() {
Administrator's avatar
Administrator committed
24

cazenave's avatar
cazenave committed
25
26
  }

Administrator's avatar
Administrator committed
27
28
29

  listdatasets() {

Administrator's avatar
Administrator committed
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49

    var myHeaders = new Headers();
        myHeaders.append("Content-Type", "Application/json");

    var myInit = { method: 'GET', headers: myHeaders};

    var myRequest = new Request('https://data.inra.fr/api/search?q=*&type=dataset',myInit);

          fetch(myRequest, myInit)
          .then(response => {          
              response.json()
                  .then(data => {
                    this.dataresult = JSON.stringify(data);
                    return this.dataresult["status"]; 
              //        console.log(this.dataresult);
                  });
              
          });
    
          return null; 
Administrator's avatar
Administrator committed
50
51
52
53
54
55
56
57



}  




cazenave's avatar
cazenave committed
58
}