Skip to content

Commit

Permalink
feat: use post request response
Browse files Browse the repository at this point in the history
  • Loading branch information
JinCoreana committed Jun 26, 2023
1 parent 8102a05 commit 628aca5
Showing 1 changed file with 1 addition and 17 deletions.
18 changes: 1 addition & 17 deletions src/pages/cvAnonymisation/CvAnonymisationPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,6 @@ const CvAnonymisationPage = () => {
const [selectedFile, setSelectedFile] = useState("");
const fileInputRef = useRef<HTMLInputElement>(null);

const fetchData = async () => {
try {
//Used direct url for now. To be refactored with proxy server
const response = await fetch(
"http://localhost:5500/cv_anonymisation/CVs/downloads/anonymized_cv.txt",
{
method: "GET",
}
);
const parsedText = await response.text();
setAnonymisedData(parsedText);
} catch (error) {
console.error("Error reading the file:", error);
}
};

const handleButtonClick = (e: any) => {
e.preventDefault();
fileInputRef.current?.click();
Expand All @@ -60,13 +44,13 @@ const CvAnonymisationPage = () => {

if (response.ok) {
console.log(response);
setAnonymisedData(response.body as unknown as string);
} else {
console.error("Anonymisation Failed", response.status);
}
} catch (error) {
console.error(error);
}
fetchData();
}
};
return (
Expand Down

0 comments on commit 628aca5

Please sign in to comment.