mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-20 20:29:06 +00:00
Finished websocket implementation
This commit is contained in:
@@ -3,7 +3,7 @@ import axios from "axios";
|
||||
|
||||
const API_URL = process.env.NEXT_PUBLIC_API_URL;
|
||||
|
||||
const useCreateTranscript = () => {
|
||||
const useTranscript = () => {
|
||||
const [response, setResponse] = useState(null);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [error, setError] = useState(null);
|
||||
@@ -15,29 +15,31 @@ const useCreateTranscript = () => {
|
||||
name: "Weekly All-Hands", // Hardcoded for now
|
||||
};
|
||||
|
||||
console.log("Sending POST:", data);
|
||||
console.debug(
|
||||
"POST - /v1/transcripts/ - Requesting new transcription creation",
|
||||
data,
|
||||
);
|
||||
|
||||
axios
|
||||
.post(url, data)
|
||||
.then((result) => {
|
||||
setResponse(result.data);
|
||||
setLoading(false);
|
||||
console.log("Response:", result.data);
|
||||
console.debug("New transcript created:", result.data);
|
||||
})
|
||||
.catch((err) => {
|
||||
setError(err.response || err);
|
||||
const errorString = err.response || err || "Unknown error";
|
||||
setError(eerrorString);
|
||||
setLoading(false);
|
||||
alert("Error: " + (err.response || err));
|
||||
console.log("Error occurred:", err.response || err); // Debugging line
|
||||
console.error("Error creating transcript:", errorString);
|
||||
});
|
||||
};
|
||||
|
||||
// You can choose when to call createTranscript, e.g., based on some dependencies
|
||||
useEffect(() => {
|
||||
createTranscript();
|
||||
}, []); // Empty dependencies array means this effect will run once on mount
|
||||
}, []);
|
||||
|
||||
return { response, loading, error, createTranscript };
|
||||
};
|
||||
|
||||
export default useCreateTranscript;
|
||||
export default useTranscript;
|
||||
|
||||
Reference in New Issue
Block a user