Added adding url functionality to apiclient

This commit is contained in:
Nicolai Ort 2021-08-21 10:51:25 +02:00
parent c5c8514bab
commit 0c629e2416
Signed by: niggl
GPG Key ID: 13AFA55AF62F269F
1 changed files with 22 additions and 0 deletions

View File

@ -1,3 +1,4 @@
import { data } from 'autoprefixer';
import axios from 'axios';
import UserStore from './UserStore';
@ -74,6 +75,27 @@ export default class Apiclient {
).data;
}
/**
* Create a new shorturl via the api
* @param {*} target The target (rediction) url for the new shorturl.
* @param {*} shortcode A custom shortcode (if needed)
* @returns The response data/error
*/
static async createUrl(target, shortcode) {
const res = (
await axios.post(`https://kauft.es/api`, {
target,
shortcode
}, {
validateStatus: null
})
);
return {
status: res.status,
data: res.data
}
}
/**
* API-Delet for the linkylinky api url deletion endpoint (needs auth)
* @param {*} shortcode The shortcode of your most hated url