#How use env variables

2 messages · Page 1 of 1 (latest)

reef bramble
#

`const apiHost = import.meta.env.VITE_API_HOST;
const apiPort = import.meta.env.VITE_API_PORT;
const listaProductosUrl = http://${apiHost}:${apiPort}/api/Productos/Lista;

<BaseLayout>
<div id="productos-container">
<!-- Aquí se mostrarán los productos -->
</div>
<script >
let productos = [];

// Hacer la solicitud a la API para obtener la lista de productos
fetch(listaProductosUrl)`

How do I pass the const with the link to the script in order to fetching the data?

rocky zephyr