30 lines
678 B
JavaScript
30 lines
678 B
JavaScript
const URI = "https://my.patachina2.casacam.net";
|
|
const USER = "fabio.micheluz@gmail.com";
|
|
const PASSW = "master66";
|
|
|
|
async function login(email, password) {
|
|
const res = await fetch(`${URI}/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(USER, PASSW);
|
|
|
|
const res = await fetch(`${URI}/links`, {
|
|
headers: {
|
|
"Authorization": `Bearer ${token}`,
|
|
"Accept": "application/json"
|
|
}
|
|
});
|
|
|
|
const json = await res.json();
|
|
console.log(json);
|
|
}
|
|
|
|
getLinks();
|