Stimulus and Ajax

This tutorial will show how to use Stimulus and Ajax.

We'll cover the following

Even though “the Hotwire way” is all about sending and receiving HTML between the client and the server, we may still need to receive plain data sometimes. For example, we may have a legacy API section of our code, or it may be useful to call a third-party API from our client. Let’s look at how we would make those API calls in our Stimulus code.

Making Ajax calls

The simplest mechanism for making Ajax calls in modern JavaScript is with the fetch function, as well as the async/await syntax for handling asynchronous behavior.

Get hands-on with 1200+ tech skills courses.