mirror of
https://github.com/versia-pub/api.git
synced 2025-12-06 08:28:19 +01:00
feat(federation): ✨ Add static get/post methods to FederationRequester
This commit is contained in:
parent
021a3485f5
commit
2dd8615db3
|
|
@ -206,6 +206,15 @@ export class FederationRequester {
|
|||
});
|
||||
}
|
||||
|
||||
public static get<ReturnType>(
|
||||
url: string | URL,
|
||||
extra?: RequestInit,
|
||||
): Promise<Output<ReturnType>> {
|
||||
const requester = new FederationRequester(new URL(url));
|
||||
|
||||
return requester.get<ReturnType>(new URL(url).pathname, extra);
|
||||
}
|
||||
|
||||
public async post<ReturnType>(
|
||||
path: string,
|
||||
body: object,
|
||||
|
|
@ -218,4 +227,14 @@ export class FederationRequester {
|
|||
throw e;
|
||||
});
|
||||
}
|
||||
|
||||
public static post<ReturnType>(
|
||||
url: string,
|
||||
body: object,
|
||||
extra?: RequestInit,
|
||||
): Promise<Output<ReturnType>> {
|
||||
const requester = new FederationRequester(new URL(url));
|
||||
|
||||
return requester.post<ReturnType>(new URL(url).pathname, body, extra);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue