Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
dad
FFDS-register-front
Commits
1daa167e
Commit
1daa167e
authored
Sep 14, 2020
by
Administrator
Browse files
api suite
parent
2f77630a
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/app/datasets/datasets.component.html
View file @
1daa167e
...
...
@@ -5,6 +5,6 @@
<div>
<button
type=
"submit"
(click)=
"listdatasets()"
class=
"btn btn-primary"
>
List datasets
</button>
</div>
<p>
{{result}}
</p>
<p>
{{
data
result}}
</p>
</form>
src/app/datasets/datasets.component.ts
View file @
1daa167e
...
...
@@ -27,43 +27,26 @@ export class DatasetsComponent implements OnInit {
listdatasets
()
{
const
httpOptions
=
{
headers
:
new
HttpHeaders
({
'
Content-Type
'
:
'
Application/json
'
})
};
const
getCircularReplacer
=
()
=>
{
const
seen
=
new
WeakSet
();
return
(
key
,
value
)
=>
{
if
(
typeof
value
===
"
object
"
&&
value
!==
null
)
{
if
(
seen
.
has
(
value
))
{
return
;
}
seen
.
add
(
value
);
}
return
value
;
};
};
// 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
());
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
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment