Commit 1daa167e authored by Administrator's avatar Administrator
Browse files

api suite

parent 2f77630a
...@@ -5,6 +5,6 @@ ...@@ -5,6 +5,6 @@
<div> <div>
<button type="submit" (click)="listdatasets()" class="btn btn-primary">List datasets</button> <button type="submit" (click)="listdatasets()" class="btn btn-primary">List datasets</button>
</div> </div>
<p>{{result}}</p> <p>{{dataresult}}</p>
</form> </form>
...@@ -27,43 +27,26 @@ export class DatasetsComponent implements OnInit { ...@@ -27,43 +27,26 @@ export class DatasetsComponent implements OnInit {
listdatasets() { listdatasets() {
const httpOptions = {
headers: new HttpHeaders({ var myHeaders = new Headers();
'Content-Type': 'Application/json' myHeaders.append("Content-Type", "Application/json");
})
}; var myInit = { method: 'GET', headers: myHeaders};
const getCircularReplacer = () => { var myRequest = new Request('https://data.inra.fr/api/search?q=*&type=dataset',myInit);
const seen = new WeakSet();
return (key, value) => { fetch(myRequest, myInit)
if (typeof value === "object" && value !== null) { .then(response => {
if (seen.has(value)) { response.json()
return; .then(data => {
} this.dataresult = JSON.stringify(data);
seen.add(value); return this.dataresult["status"];
} // console.log(this.dataresult);
return value; });
};
}; });
return null;
// remplacer l'url api dataverse avec l'enpoint du smart harvester "datasetslist"
this.result = new Promise((r, e) => {
r(this.http.get("https://data.inra.fr/api/search?q=*&type=dataset", httpOptions ).subscribe(r => console.log(r)));
})
this.result.then(
(res) => {
console.log("res = " + JSON.stringify(res, getCircularReplacer()));
this.dataresult = res;
console.log("this.dataresult = " + JSON.stringify(this.dataresult, getCircularReplacer()));
return this.dataresult;
});
console.log(JSON.stringify(this.dataresult, getCircularReplacer()));
return JSON.stringify(this.dataresult, getCircularReplacer());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment