forked from core-api/javascript-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbrowser.html
More file actions
38 lines (30 loc) · 1.03 KB
/
browser.html
File metadata and controls
38 lines (30 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<!DOCTYPE html>
<html>
<head>
<title>Example</title>
</head>
<body>
<h1>Hello!</h1>
<h3 id="response">Status (waiting)</h3>
<script src="../dist/coreapi.js"></script>
<script type="text/javascript">
var coreapi = window.coreapi;
var client = new coreapi.Client();
// Examples
// Text: http://www.mocky.io/v2/582321ea1000008610ccfea6
// JSON: http://www.mocky.io/v2/582321ba1000006310ccfea5
client.get("http://www.mocky.io/v2/582321ea1000008610ccfea6")
.then(function (data) {
var responseElement = document.getElementById("response");
if (typeof data === 'string') {
responseElement.innerText = 'Text: ' + data;
} else if (typeof data === 'object') {
responseElement.innerText = 'JSON: ' + JSON.stringify(data);
}
})
.catch(function (error) {
console.log("ERROR: ", error);
});
</script>
</body>
</html>