mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-02-27 12:16:36 +00:00
Ensured domain is passed when loading visits for a short URL on a specific domain
This commit is contained in:
@@ -12,6 +12,7 @@ export const apiErrorType = PropTypes.shape({
|
||||
});
|
||||
|
||||
const buildShlinkBaseUrl = (url, apiVersion) => url ? `${url}/rest/v${apiVersion}` : '';
|
||||
const rejectNilProps = (options = {}) => reject(isNil, options);
|
||||
|
||||
export default class ShlinkApiClient {
|
||||
constructor(axios, baseUrl, apiKey) {
|
||||
@@ -22,7 +23,7 @@ export default class ShlinkApiClient {
|
||||
}
|
||||
|
||||
listShortUrls = pipe(
|
||||
(options = {}) => reject(isNil, options),
|
||||
rejectNilProps,
|
||||
(options) => this._performRequest('/short-urls', 'GET', options).then((resp) => resp.data.shortUrls)
|
||||
);
|
||||
|
||||
@@ -37,20 +38,20 @@ export default class ShlinkApiClient {
|
||||
this._performRequest(`/short-urls/${shortCode}/visits`, 'GET', query)
|
||||
.then((resp) => resp.data.visits);
|
||||
|
||||
getShortUrl = (shortCode) =>
|
||||
this._performRequest(`/short-urls/${shortCode}`, 'GET')
|
||||
getShortUrl = (shortCode, domain) =>
|
||||
this._performRequest(`/short-urls/${shortCode}`, 'GET', { domain })
|
||||
.then((resp) => resp.data);
|
||||
|
||||
deleteShortUrl = (shortCode) =>
|
||||
this._performRequest(`/short-urls/${shortCode}`, 'DELETE')
|
||||
deleteShortUrl = (shortCode, domain) =>
|
||||
this._performRequest(`/short-urls/${shortCode}`, 'DELETE', { domain })
|
||||
.then(() => ({}));
|
||||
|
||||
updateShortUrlTags = (shortCode, tags) =>
|
||||
this._performRequest(`/short-urls/${shortCode}/tags`, 'PUT', {}, { tags })
|
||||
updateShortUrlTags = (shortCode, domain, tags) =>
|
||||
this._performRequest(`/short-urls/${shortCode}/tags`, 'PUT', { domain }, { tags })
|
||||
.then((resp) => resp.data.tags);
|
||||
|
||||
updateShortUrlMeta = (shortCode, meta) =>
|
||||
this._performRequest(`/short-urls/${shortCode}`, 'PATCH', {}, meta)
|
||||
updateShortUrlMeta = (shortCode, domain, meta) =>
|
||||
this._performRequest(`/short-urls/${shortCode}`, 'PATCH', { domain }, meta)
|
||||
.then(() => meta);
|
||||
|
||||
listTags = () =>
|
||||
@@ -73,7 +74,7 @@ export default class ShlinkApiClient {
|
||||
method,
|
||||
url: `${buildShlinkBaseUrl(this._baseUrl, this._apiVersion)}${url}`,
|
||||
headers: { 'X-Api-Key': this._apiKey },
|
||||
params: query,
|
||||
params: rejectNilProps(query),
|
||||
data: body,
|
||||
paramsSerializer: (params) => qs.stringify(params, { arrayFormat: 'brackets' }),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user