feat: connect backend with the frontend

This commit is contained in:
2025-07-23 15:02:32 +00:00
parent aacba52807
commit a2a21acbb3
11 changed files with 54 additions and 20 deletions

View File

@@ -1,11 +1,11 @@
import { ShortenUrlRequest, ShortenUrlResponse } from "./types";
const baseUrl = process.env.REACT_APP_API_BASE_URL
export async function shortenUrlApi(
payload: ShortenUrlRequest
): Promise<ShortenUrlResponse> {
/* TODO
const response = await fetch('https://api.minxa.lol/api/v1/url', {
const response = await fetch(`${baseUrl}/`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(payload),
@@ -14,10 +14,11 @@ export async function shortenUrlApi(
if (!response.ok) {
throw new Error('Failed to shorten URL');
}
*/
const data = await response.json()
return {
shortCode: 'Ux5vy' // Dummy value return
url: data.url,
shortcode: data.shortcode
}
}