-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
22 lines (22 loc) · 776 Bytes
/
index.html
File metadata and controls
22 lines (22 loc) · 776 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<html>
<head>
<title>eLabFTW api demo</title>
<body>
<h1>Accessing the eLabFTW API through javascript</h1>
<h2>Reading experiments</h2>
<button id='getExp'>Read experiments</button>
<div id='output'></div>
</body>
<script>
// CHANGE THIS
const elabftwServerUrl = 'https://elab.local:3148/api/v2';
const apiKey = 'apiKey4Test';
// END configuration
document.getElementById('getExp').addEventListener('click', () => {
const headers = {'Content-Type': 'application/json', 'Authorization': apiKey};
fetch(`${elabftwServerUrl}/experiments`, { headers, method: 'GET'}).then(res => res.json()).then(json => {
document.getElementById('output').innerText = JSON.stringify(json);
});
});
</script>
</html>