In this tutorial, you'll learn how to use the fetch API to connect to an external service and display data items retrieved from that service. Site visitors can click a button to fetch and display a collection of greetings in different languages.
Note: To see this example in action, see Hello Fetch.
By the end of this tutorial, you'll have a working example that fetches greetings data from an external API and displays it on your site using a repeater element.

Add the following elements to your page:
fetchGreetingsButton.greetingsRepeater.repeatedLanguage.repeatedGreeting.Create a new web module file called dataFetcher.web.js and add the following code to fetch greetings from an external API:
In the code for the page where you added the elements above:
Add the import statement, hide the repeater, and set up a button click event handler:
Disable the button during fetch to prevent multiple clicks:
Call the backend function to retrieve the greetings data:
Transform the data by adding _id properties, as required by repeater elements:
Populate the repeater with the transformed data:
Make the previously hidden repeater visible:
Change the button label to indicate completion:
This completes the code requirements within the onReady function.
In a new code block, set up how each item in the repeater displays its data: