32 lines
535 B
JavaScript
32 lines
535 B
JavaScript
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} |