init login

This commit is contained in:
2023-11-23 17:26:09 +01:00
parent 267eeab896
commit ea42d10ddf
4 changed files with 81 additions and 2 deletions

View File

@ -0,0 +1,32 @@
class Client
{
constructor(url)
{
this._url = url;
this._token = undefined;
}
get isAuthentificate()
{
return this.token != undefined;
}
async _post(uri, data)
{
let response = await fetch(this._url + uri, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(data),
});
return response;
}
async login(username, password)
{
return this._post("/api/accounts/login", {username: username, password: password})
}
}
export {Client}