31 lines
739 B
JavaScript
31 lines
739 B
JavaScript
|
const serverUrl = "http://localhost:8081";
|
||
|
let forma = document.querySelector("#for-test");
|
||
|
let val;
|
||
|
function getAllUsers(){
|
||
|
return fetch(`${serverUrl}/users`)
|
||
|
.then((response) => {
|
||
|
return response.json();
|
||
|
});
|
||
|
}
|
||
|
|
||
|
export function testForm(){
|
||
|
let toRet = '';
|
||
|
return getAllUsers().then(res => {
|
||
|
res.forEach((user, index) => {
|
||
|
toRet += user.email;
|
||
|
toRet+=' ';
|
||
|
});
|
||
|
forma.innerHTML += toRet;
|
||
|
});
|
||
|
}
|
||
|
|
||
|
export async function testForm2(){
|
||
|
const res = await fetch(`${serverUrl}/users`);
|
||
|
const data = await res.json();
|
||
|
let toRet = '';
|
||
|
data.forEach((user, index) => {
|
||
|
toRet += user.email;
|
||
|
toRet+=' ';
|
||
|
});
|
||
|
forma.innerHTML += toRet;
|
||
|
}
|