Skip to content

Commit

Permalink
Deploy explain API
Browse files Browse the repository at this point in the history
  • Loading branch information
vjspranav committed Feb 16, 2024
1 parent 9e32371 commit da1324f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/Constants.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const API_URL = "https://api.stagb.in/dev/content/";
const EXPLAIN_URL = "https://api.stagb.in/dev/explain/";
const RAW_URL = "https://raw.stagb.in/StagBIN-Raw/";

export { API_URL, RAW_URL };
export { API_URL, RAW_URL, EXPLAIN_URL };
15 changes: 11 additions & 4 deletions src/components/MonacoEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import Backdrop from "@material-ui/core/Backdrop";
import CircularProgress from "@material-ui/core/CircularProgress";
import { Box, makeStyles } from "@material-ui/core";

import { API_URL } from "../Constants";
import { API_URL, EXPLAIN_URL } from "../Constants";
import { StagBinContext } from "../App";
import detectLanguage from "../utils/language";

Expand Down Expand Up @@ -111,13 +111,20 @@ export default function MEditor() {

const handleOpen = () => {
setOpen(true);
setInterval(() => {
setExplanation("We are still learning...");
}, 3000);
axios
.post(EXPLAIN_URL, { data: data })
.then((res) => {
setExplanation(res.data.body);
})
.catch((err) => {
console.log(err);
setExplanation("Failed to understand the content");
});
};

const handleClose = () => {
setOpen(false);
setExplanation("");
};

useEffect(() => {
Expand Down

0 comments on commit da1324f

Please sign in to comment.