Skip to content

Commit 6093da3

Browse files
committed
error Error loading cat data
1 parent 2513719 commit 6093da3

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

chapters/endpoints.qmd

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ lightbox: true
1414
1515
// Load the pre-fetched cat data
1616
cats = FileAttachment("../_data/cats.json").json()
17+
console.log(cats)
1718
```
1819

1920
In the terminology of APIs, an **endpoint** is a URL that specifies the location of a resource on a server. As we saw with the cat API, most of the time you can access the data from an endpoint without requiring any particular software besides a web browser.
@@ -79,8 +80,10 @@ With this result:
7980
<script>
8081
document.addEventListener('DOMContentLoaded', async () => {
8182
try {
82-
// Wait for OJS runtime to be ready and access the cats variable
83-
const cats = await window.ojs.runtime.interpret('cats');
83+
// Wait for Observable runtime to be ready
84+
await document.querySelector('ojs-provider').whenDefined();
85+
const runtime = document.querySelector('ojs-provider').value;
86+
const cats = await runtime.value('cats');
8487

8588
const wrapper = document.querySelector('.carousel-wrapper');
8689
cats.forEach(cat => {

0 commit comments

Comments
 (0)