Update api.ts
This commit is contained in:
parent
4f48f3065c
commit
2d095dc6b2
|
|
@ -51,7 +51,7 @@ export function api<E extends keyof Misskey.Endpoints, P extends Misskey.Endpoin
|
||||||
return promise;
|
return promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function apiExternal<E extends keyof Misskey.Endpoints, P extends Misskey.Endpoints[E]['req']>(hostUrl: string, endpoint: E, data: P = {} as any, token?: string | null | undefined, signal?: AbortSignal): Promise<Misskey.Endpoints[E]['res']> {
|
export async function apiExternal<E extends keyof Misskey.Endpoints, P extends Misskey.Endpoints[E]['req']>(hostUrl: string, endpoint: E, data: P = {} as any, token?: string | null | undefined, signal?: AbortSignal): Promise<Misskey.Endpoints[E]['res']> {
|
||||||
if (!/^https?:\/\//.test(hostUrl)) throw new Error('invalid host name');
|
if (!/^https?:\/\//.test(hostUrl)) throw new Error('invalid host name');
|
||||||
if (endpoint.includes('://')) throw new Error('invalid endpoint');
|
if (endpoint.includes('://')) throw new Error('invalid endpoint');
|
||||||
const knownUrls = (await api('federation/instances', { blocked: false })).map(v => v.host);
|
const knownUrls = (await api('federation/instances', { blocked: false })).map(v => v.host);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue