| 1 | --- |
| 2 | title: "htmx:after:request" |
| 3 | description: "After response is received" |
| 4 | --- |
| 5 | |
| 6 | The `htmx:after:request` event fires immediately after the `fetch()` call resolves and the response is received. |
| 7 | |
| 8 | ## When It Fires |
| 9 | |
| 10 | After the server responds, before content swapping occurs. |
| 11 | |
| 12 | ## Event Detail |
| 13 | |
| 14 | - `ctx` - Request context including response data |
| 15 | |
| 16 | ## Example |
| 17 | |
| 18 | ```javascript |
| 19 | htmx.on('htmx:after:request', (evt) => { |
| 20 | console.log('Response status:', evt.detail.ctx.response.status); |
| 21 | // Hide loading indicator |
| 22 | }); |
| 23 | ``` |
| 24 | |
| 25 | The response is available but hasn't been swapped into the DOM yet. |