From e9874b13eabc12ac93cc42c8f5496bcdd5de1d63 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Yadav Date: Sun, 11 Jan 2026 19:49:30 +0530 Subject: [PATCH 1/3] feat: add interactive Try It panel to API docs --- frontend/src/components/TryItPanel.jsx | 65 ++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 frontend/src/components/TryItPanel.jsx diff --git a/frontend/src/components/TryItPanel.jsx b/frontend/src/components/TryItPanel.jsx new file mode 100644 index 000000000..4fc704c6d --- /dev/null +++ b/frontend/src/components/TryItPanel.jsx @@ -0,0 +1,65 @@ +import { useState } from "react"; + +export default function TryItPanel({ endpoint, method = "POST" }) { + const [apiKey, setApiKey] = useState(""); + const [jsonBody, setJsonBody] = useState(`{}`); + const [response, setResponse] = useState(""); + const [status, setStatus] = useState(""); + + async function sendRequest() { + try { + const res = await fetch(`https://api.urbackend.bitbros.in${endpoint}`, { + method, + headers: { + "Content-Type": "application/json", + "x-api-key": apiKey, + }, + body: method !== "GET" ? jsonBody : null, + }); + + const data = await res.text(); + setStatus(res.status); + setResponse(data); + } catch (err) { + setResponse(err.message); + } + } + + return ( +
+
+ + setApiKey(e.target.value)} + placeholder="sk_live_xxxxx" + /> +
+ +
+ +