refactoring save upload to match mod upload

This commit is contained in:
Jan Naahs 2020-10-24 12:25:30 +02:00
parent a0952f7301
commit 82a8a8d6e5
2 changed files with 5 additions and 6 deletions

View File

@ -8,12 +8,11 @@ const UploadSaveForm = ({onSuccess}) => {
const {register, handleSubmit, errors} = useForm();
const [fileName, setFileName] = useState('Select File ...');
const onSubmit = async (data, e) => {
const res = await saves.upload(data.savefile);
if (res.success) {
const onSubmit = (data, e) => {
saves.upload(data.savefile[0]).then(_ => {
e.target.reset();
onSuccess();
}
})
};
return (

View File

@ -13,9 +13,9 @@ export default {
const response = await client.get(`/api/saves/create/${name}`);
return response.data;
},
upload: async (data) => {
upload: async file => {
let formData = new FormData();
formData.append("savefile", data[0]);
formData.append("savefile", file);
const response = await client.post(`/api/saves/upload`, formData, {
headers: {