ft_transcendence/frontend/static/js/api/profile.js

35 lines
702 B
JavaScript
Raw Normal View History

2023-12-06 09:19:41 -05:00
class Profile
{
2023-12-08 11:36:41 -05:00
constructor (client, username = undefined, avatar_url = undefined, user_id = undefined)
2023-12-06 09:19:41 -05:00
{
this.client = client;
2023-12-08 11:36:41 -05:00
this.username = username;
this.avatar_url = avatar_url
this.user_id = user_id
2023-12-06 09:19:41 -05:00
}
async init(id)
{
let response = await this.client._get(`/api/profiles/${id}`);
let response_data = await response.json();
this.id = id;
this.username = response_data.username;
this.avatar_url = response_data.avatar_url;
}
async change_avatar(form_data)
{
let response = await this.client._patch_file(`/api/profiles/${this.id}`, form_data);
let response_data = await response.json()
return response_data;
}
async setData (data)
{
}
}
export {Profile}