Skip to content

Commit c59198f

Browse files
committed
check ojs environment
1 parent 6093da3 commit c59198f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

chapters/endpoints.qmd

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,22 @@ lightbox: true
1515
// Load the pre-fetched cat data
1616
cats = FileAttachment("../_data/cats.json").json()
1717
console.log(cats)
18+
19+
// Create a container div for our carousel
20+
viewof carousel = {
21+
const wrapper = html`<div class="carousel-wrapper"></div>`;
22+
23+
cats.then(data => {
24+
data.forEach(cat => {
25+
const img = document.createElement('img');
26+
img.src = cat.url;
27+
img.alt = 'Cat image';
28+
wrapper.appendChild(img);
29+
});
30+
});
31+
32+
return wrapper;
33+
}
1834
```
1935

2036
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.

0 commit comments

Comments
 (0)