Skip to content

Commit

Permalink
Implemented uploading PDF
Browse files Browse the repository at this point in the history
  • Loading branch information
daminort committed Aug 27, 2020
1 parent bb00790 commit e278c4b
Show file tree
Hide file tree
Showing 9 changed files with 321 additions and 10 deletions.
201 changes: 201 additions & 0 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
"@testing-library/react": "^9.3.2",
"@testing-library/user-event": "^7.1.2",
"antd": "^4.5.4",
"axios": "^0.20.0",
"node-sass": "^4.14.1",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-scripts": "3.4.3"
"react-scripts": "3.4.3",
"react-use": "^15.3.3"
},
"scripts": {
"start": "react-scripts start",
Expand Down
30 changes: 30 additions & 0 deletions client/src/api/server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import axios from 'axios';

const apiHost = 'http://localhost:3001';
const baseURL = `${apiHost}/pdf`;

async function uploadFile(file) {
console.log('server.js [7]:', { file });

const formData = new FormData();
formData.append('document', file);

console.log('server.js [10]:', { formData });

const result = await axios.post(baseURL, formData, {
headers: {},
// headers: {
// 'Content-Type': 'multipart/form-data',
// },
});
if (result?.error) {
console.error('Error: ', result?.error);
return null;
}

return result;
}

export {
uploadFile,
}
Loading

0 comments on commit e278c4b

Please sign in to comment.