0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2025-02-10 22:38:53 -05:00
astro/.changeset/wise-boxes-develop.md

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

21 lines
705 B
Markdown
Raw Normal View History

2024-12-11 16:56:32 +01:00
---
'astro': minor
---
Exports a new `getActionPath()` helper from `astro:actions`
In most cases, calling an action as `actions.like()` is enough. But sometimes it's not enough, for example:
- You want to pass custom headers
- You want to call the actions endpoint without `fetch`, eg. using the `navigator.sendBeacon` API
That's why you can now use the `getActionPath()` helper. Pass an action to it to get the pathname (prefixed by your `based` configuration) to the action:
```ts
import { actions, getActionPath } from 'astro:actions'
const path = getActionPath(actions.like) // '/_actions/like'
```
If you intent to use this server side, remember to supply a hostname (eg. using `Astro.site`).