Skip to content

Commit

Permalink
Added axios post route
Browse files Browse the repository at this point in the history
  • Loading branch information
Siddharth Gaikwad authored and Siddharth Gaikwad committed Feb 16, 2024
1 parent 9bd3080 commit b4623a5
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions frontend/src/components/FileUploader.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

import axios from 'axios';
import React, { ChangeEvent, useState } from 'react';


const FileUploader: React.FC = () => {
const [selectedFile, setSelectedFile] = useState<File | null>(null);

Expand All @@ -14,10 +16,17 @@ const FileUploader: React.FC = () => {

const handleFileUpload = () => {
if (selectedFile) {
console.log('File selected for upload:', selectedFile.name);
alert(`File selected for upload: ${selectedFile.name}`);
} else {
alert('No file selected.');
}

axios.post(`/upload`, { selectedFile })
.then(res => {
console.log(res);
console.log(res.data);
})
};

return (
Expand Down

0 comments on commit b4623a5

Please sign in to comment.