1
respuesta

¡Ayuda!ERR_CONNECTION_REFUSED

El navegador me marca un error: Failed to load resource: net::ERR_CONNECTION_REFUSED. Es como que no conectara con el servidor Me marca la linea 49: http.send();

copio el código completo:

const crearNuevaLinea = (nombre,email) => {     
    const linea = document.createElement("tr");
    const contenido = 
            `<td class="td" data-td>
            ${nombre}
            </td>
            <td> ${email} </td>
            <td>
              <ul class="table__button-control">
                <li>
                  <a
                    href="../screens/editar_cliente.html"
                    class="simple-button simple-button--edit"
                    >Editar</a
                  >
                </li>
                <li>
                  <button
                    class="simple-button simple-button--delete"
                    type="button"
                  >
                    Eliminar
                  </button>
                </li>
              </ul>
            </td>`
    linea.innerHTML = contenido;
    return linea;
};

const table = document.querySelector("[data-table]")

const http = new XMLHttpRequest();



http.open("GET", "http://localhost:3000/perfil");

http.send();

http.onload = () =>{
    const data = JSON.parse(http.response);
    data.forEach( (perfil) =>{
        const nuevaLinea = crearNuevaLinea(perfil.nombre, perfil.email);
        table.appendChild(nuevaLinea);
    })
}

¿Cómo puedo solucionar el problema?

1 respuesta

Me va el mismo error :c