Home > Web Front-end > JS Tutorial > Learn how to create a API-backed Zelda BOTW monster gallery web component in

Learn how to create a API-backed Zelda BOTW monster gallery web component in
PHPz
Release: 2024-09-03 13:33:32
Original
1172 people have browsed it

Modulo tutorials are back!

Hey all! I'm back with Modulo tutorials after a summer hiatus. I've got a bunch more tutorials in the works -- so stay tuned. That said, if you have any particular ideas for my next topic, be sure to let me know in the comments!

My last tutorial was a super quick and fun "HTML-only, no-JS" tutorial on API-driven Pokémon Dance Party component in less than 30 lines of HTML Web Component code. Some of my previous tutorials were a bit more serious, such as this more advanced tutorial on managing private and public state. If that sounds a little dry, then you're in luck, because today's tutorial is another fun one, and about yet another beloved video game... Zelda: Breath of the Wild!

Of course, as always, the techniques learned in this tutorial are applicable to any API, so keep on reading to learn more about an API-driven gallery!

How to use the Hyrule Compendium API

This tutorial is 100% thanks to the wonderful Aarav Borthakur's free, MIT-licensed, and generously hosted Hyrule Compendium API, which is a fun, fan-maintained database and API for retrieval of Zelda: Breath of the Wild franchise information and media. We will be using the "Monsters" endpoint, available here: https://botw-compendium.herokuapp.com/api/v3/compendium/category/monsters

Screenshot

Learn how to create a API-backed Zelda BOTW monster gallery web component in <lines (Modulo.js)

Try it out now, in less than 30 seconds: ??? Wanna skip ahead? Scroll to the end and copy the 39 lines of HTML code into any local HTML file, and then open it in your browser. Modulo has no dependencies and even runs embedded in local HTML files, so it's really that easy!


Start with the data

Let's start with just 6 lines of code, with a StaticData and a Template to display it:

<Template>
   <pre class="brush:php;toolbar:false">API DATA: {{ staticdata|json:2 }}
Copy after login

In this snippet, we have a very simple, one-line