init login
This commit is contained in:
32
frontend/static/js/api/client.js
Normal file
32
frontend/static/js/api/client.js
Normal 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}
|
Reference in New Issue
Block a user