injext client
This commit is contained in:
parent
bc97d009ae
commit
0cbcab6597
5 changed files with 38 additions and 34 deletions
|
@ -1,8 +1,8 @@
|
|||
import { Post } from './posts.ts'
|
||||
import client from '../../api/client.ts'
|
||||
import { ApiClient } from '../../api/client.ts'
|
||||
|
||||
export class PostsService {
|
||||
constructor() {}
|
||||
constructor(private readonly client: ApiClient) {}
|
||||
|
||||
async createNew(
|
||||
authorId: string,
|
||||
|
@ -10,7 +10,7 @@ export class PostsService {
|
|||
media: CreatePostMedia[],
|
||||
isPublic: boolean,
|
||||
): Promise<string> {
|
||||
const response = await client.POST('/posts', {
|
||||
const response = await this.client.POST('/posts', {
|
||||
body: {
|
||||
authorId,
|
||||
content,
|
||||
|
@ -30,7 +30,7 @@ export class PostsService {
|
|||
}
|
||||
|
||||
async loadPublicFeed(cursor: string | null, amount: number | null): Promise<Post[]> {
|
||||
const response = await client.GET('/posts', {
|
||||
const response = await this.client.GET('/posts', {
|
||||
query: { cursor, amount },
|
||||
credentials: 'include',
|
||||
})
|
||||
|
@ -47,7 +47,7 @@ export class PostsService {
|
|||
cursor: string | null,
|
||||
amount: number | null,
|
||||
): Promise<Post[]> {
|
||||
const response = await client.GET('/posts', {
|
||||
const response = await this.client.GET('/posts', {
|
||||
params: {
|
||||
query: { From: cursor ?? undefined, Amount: amount ?? undefined, Author: username },
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue