Skip to content

Instantly share code, notes, and snippets.

@pipethedev
Last active April 10, 2022 22:45
Show Gist options
  • Save pipethedev/734771371b5de966d2e9ec80282d9005 to your computer and use it in GitHub Desktop.
Save pipethedev/734771371b5de966d2e9ec80282d9005 to your computer and use it in GitHub Desktop.
Media upload with formdata
import axis from 'axios';
const formData = new FormData();
formData.append("assigned_page", "Room page");
formData.append("name", "Test Project");
formData.append("media", this.state.selectedFile);
async function upload(){
return await axios.post("<api_endpoint>", formData, {
headers: {
"Content-Type": "multipart/form-data",
},
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment