add: profiles.all()

This commit is contained in:
2023-12-08 17:36:41 +01:00
parent 54afa8aae5
commit 0edcd97f94
6 changed files with 37 additions and 4 deletions

View File

@ -1,5 +1,6 @@
import { Account } from "./account.js";
import { Profile } from "./profile.js";
import { Profiles } from "./profiles.js";
function getCookie(name)
{
@ -17,6 +18,7 @@ class Client
{
this._url = url;
this.account = new Account(this);
this.profiles = new Profiles(this);
this._logged = undefined;
}

View File

@ -1,10 +1,11 @@
class Profile
{
constructor (client)
constructor (client, username = undefined, avatar_url = undefined, user_id = undefined)
{
this.client = client;
this.username = undefined;
this.avatar_url = undefined
this.username = username;
this.avatar_url = avatar_url
this.user_id = user_id
}
async init(id)

View File

@ -0,0 +1,23 @@
import { Profile } from "./profile.js";
class Profiles
{
constructor (client)
{
this.client = client
}
async all()
{
let response = await this.client._get("/api/profiles/");
let response_data = await response.json();
let profiles = []
response_data.forEach((profile) => {
profiles.push(new Profile(this.client, profile.username, profile.avatar_url, profile.user_id))
});
console.log(profiles);
}
}
export {Profiles}