diff --git a/src/lib/Apiclient.js b/src/lib/Apiclient.js index 70f9104..76f3ab9 100644 --- a/src/lib/Apiclient.js +++ b/src/lib/Apiclient.js @@ -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