#astro.url.searchparams on component
3 messages · Page 1 of 1 (latest)
Hi @slim cairn. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
Based on the provided knowledge sources, it seems that you might be trying to use a deprecated feature of Astro. In Astro v3.0, the Astro.request.params API was deprecated and it was removed entirely in Astro v4.0. The supported replacement is Astro.params.
Here's how you can use it:
---
const { id } = Astro.params;
let data = [];
if (id) {
const response = await fetch(`<http://127.0.0.1:8000/faltas?id=${id}`>);
data = await response.json();
}
---
Astro.params is an object containing the values of dynamic route segments matched for this request. In static builds, this will be the params returned by getStaticPaths() used for prerendering dynamic routes. In SSR builds, this can be any value matching the path segments in the dynamic route pattern.