chore: init
This commit is contained in:
commit
8424b7b98b
27 changed files with 7424 additions and 0 deletions
24
api-client/index.ts
Normal file
24
api-client/index.ts
Normal file
|
@ -0,0 +1,24 @@
|
|||
import { Headers, createFetch, fetch } from 'ohmyfetch'
|
||||
import type { Post } from './types'
|
||||
|
||||
export interface MastodonClientOptions {
|
||||
host: string
|
||||
}
|
||||
|
||||
export class Client {
|
||||
$fetch: ReturnType<typeof createFetch> = undefined!
|
||||
|
||||
constructor(public options: MastodonClientOptions) {
|
||||
this.$fetch = createFetch({
|
||||
defaults: {
|
||||
baseURL: options.host,
|
||||
},
|
||||
fetch,
|
||||
Headers,
|
||||
})
|
||||
}
|
||||
|
||||
getPublicTimeline(): Promise<Post[]> {
|
||||
return this.$fetch('/api/v1/timelines/public')
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue