ft_transcendence/frontend/static/js/api/client.js

32 lines
535 B
JavaScript
Raw Normal View History

2023-11-23 11:26:09 -05:00
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}