I have an astro component, which i want to be able to redirect, using the slug route params to another page. The problem is, i am getting the slug inside the --- but i am calling the "click" eventListener inside the script tag, so its not getting the proper scope to get the variable.
---
import StandardGreenButton from "./StandardGreenButton.astro";
import servicesService from "../../services/services.service";
const slugify = Astro.params.slugify!;
const service = await servicesService.findBySlugify(slugify);
---
<script>
const btnContinuar = document.getElementById('modalButtonConfirm')
const btnCancelar = document.getElementById('cancelar')
btnContinuar!.addEventListener('click', () => {
// alert(window.location.hostname)
if (window.location.hostname == 'localhost') {
window.location.href = `http://localhost:3000/servicos/solicitar/${slugify}`
}
})
</script>
How can i achieve that?