Skip to content

Commit

Permalink
Feat (media): Add media functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
CynthiaBorotPNV committed Nov 6, 2024
1 parent 64fb57d commit fc035ef
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
14 changes: 14 additions & 0 deletions js/media.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
async function addMedia2Json(speciesDict) {
console.log("addMedia2Json");
for(key in speciesDict) {
url = 'https://api.gbif.org/v1/species/' + speciesDict[key]["gbifId"] + '/media';
console.log(url + "<br>");
await fetch(url,{method:'GET'})
.then(function(response) {return response.json(); })
.then(function(json) {
speciesDict[key]["media"] = json.results[0].identifier
});
}
console.log(speciesDict);
return speciesDict;
}
15 changes: 15 additions & 0 deletions media.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<html>
<body>
<script type="text/javascript" source="js/media.js"></script>
<script type="text/javascript">
speciesObj = new Object();
speciesObj = {
"Primula verna": {"cd_ref":11232121, "gbifId":5231190, "count":3},
"Acer campestre": {"cd_ref":11256121, "gbifId":8250742, "count":45},
"Poa annua": {"cd_ref":13256121, "gbifId":2495696, "count":18}
}

addMedia2Json(speciesObj);
</script>
</body>
</html>

0 comments on commit fc035ef

Please sign in to comment.