"use client"; import { useState } from "react"; import axios from "axios"; import dotenv from "dotenv"; dotenv.config({ path: "./.env.local" }); export default function Home() { const [longUrl, setLongUrl] = useState(""); const [shortUrl, setShortUrl] = useState(""); const handleSubmit = async (e) => { e.preventDefault(); const response = await axios.post( `${process.env.NEXT_PUBLIC_BACKEND_URL}/shorten`, { long_url: longUrl, }, ); setShortUrl(response.data.short_url); }; return (
Short URL:{" "} {shortUrl}
)}