add: profile avatar
This commit is contained in:
34
frontend/static/js/api/profile.js
Normal file
34
frontend/static/js/api/profile.js
Normal file
@ -0,0 +1,34 @@
|
||||
class Profile
|
||||
{
|
||||
constructor (client)
|
||||
{
|
||||
this.client = client;
|
||||
this.username = undefined;
|
||||
this.avatar_url = undefined
|
||||
}
|
||||
|
||||
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}
|
Reference in New Issue
Block a user