PHP Classes

File: js/getUsers.js

Recommend this page to a friend!
  Classes of Rodrigo Faustino   PHP AJAX Login with JWT and Fetch API   js/getUsers.js   Download  
File: js/getUsers.js
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: PHP AJAX Login with JWT and Fetch API
Login users using AJAX to send JWT to a server API
Author: By
Last change:
Date: 5 months ago
Size: 1,167 bytes
 

Contents

Class file image Download
document.addEventListener("DOMContentLoaded", async function() { const urlBase="http://localhost:8089/" async function buscaUsers() { try { const response = await fetch(`${urlBase}backend/Router/UsuarioRouter.php`, { method: 'GET', }); const jsonResponse = await response.json(); const lista = document.querySelector("#users"); lista.classList.add("row"); jsonResponse.usuarios.forEach(usuario => { console.log(usuario) const container = document.createElement("div"); container.classList.add("card"); container.innerHTML = ` <div class="container"> <h3>Dados no banco com criptografado</h3> <p>Id: ${usuario.id}</p> <h3>Nome: ${usuario.nome}</h3> <p>Email: ${usuario.email}</p> <p>Criação: ${usuario.criado}</p> </div> `; lista.appendChild(container); }); } catch (error) { console.error(error); } } buscaUsers() });