Created component to allow selecting from existing domains list

This commit is contained in:
Alejandro Celaya
2020-11-25 21:05:27 +01:00
parent 2a7c2474cd
commit 983e4db3b1
12 changed files with 210 additions and 4 deletions

View File

@@ -13,6 +13,8 @@ import {
ShlinkVisits,
ShlinkVisitsParams,
ShlinkShortUrlMeta,
ShlinkDomain,
ShlinkDomainsResponse,
} from './types';
const buildShlinkBaseUrl = (url: string, apiVersion: number) => url ? `${url}/rest/v${apiVersion}` : '';
@@ -93,6 +95,9 @@ export default class ShlinkApiClient {
this.performRequest<ShlinkMercureInfo>('/mercure-info', 'GET')
.then((resp) => resp.data);
public readonly listDomains = async (): Promise<ShlinkDomain[]> =>
this.performRequest<{ domains: ShlinkDomainsResponse }>('/domains', 'GET').then(({ data }) => data.domains.data);
private readonly performRequest = async <T>(url: string, method: Method = 'GET', query = {}, body = {}): Promise<AxiosResponse<T>> => {
try {
return await this.axios({

View File

@@ -64,3 +64,12 @@ export interface ProblemDetailsError {
message?: string; // Deprecated
[extraProps: string]: any;
}
export interface ShlinkDomain {
domain: string;
isDefault: boolean;
}
export interface ShlinkDomainsResponse {
data: ShlinkDomain[];
}