Last active
September 30, 2021 22:46
-
-
Save guiathayde/d2bacb630613cf2118cd121d278bf676 to your computer and use it in GitHub Desktop.
Requisição POST para criação de nova instituição
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const onDropFiles = useCallback((files: any) => { | |
const formData = new FormData(); | |
formData.append('data', JSON.stringify(institution)); // Object with all the institution's data | |
formData.append('profileImage', files[0]); | |
formData.append('galleryImages', files[1]); | |
formData.append('galleryImages', files[2]); | |
formData.append('galleryImages', files[3]); | |
formData.append('galleryImages', files[4]); | |
axios | |
.post(`${process.env.API_URL}/api/institutions`, formData, { | |
headers: { | |
Authorization: | |
`Bearer ${token}`, | |
'Content-Type': 'multipart/form-data', | |
}, | |
}) | |
.then(responseAxios => { | |
console.log('Deu certo!!!', responseAxios); | |
}) | |
.catch(error => { | |
console.log('Deu errado!!!', error); | |
}); | |
}, []); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment