26 lines
622 B
JavaScript
26 lines
622 B
JavaScript
async function login(email, password) {
|
|
const res = await fetch("http://192.168.1.3:3000/auth/login", {
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
body: JSON.stringify({ email, password })
|
|
});
|
|
|
|
const data = await res.json();
|
|
return data.token;
|
|
}
|
|
|
|
async function getLinks() {
|
|
const token = await login("fabio.micheluz@gmail.com", "master66");
|
|
|
|
const res = await fetch("http://192.168.1.3:3000/links", {
|
|
headers: {
|
|
"Authorization": `Bearer ${token}`,
|
|
"Accept": "application/json"
|
|
}
|
|
});
|
|
|
|
const json = await res.json();
|
|
console.log(json);
|
|
}
|
|
|
|
getLinks();
|