Created
November 30, 2018 14:29
-
-
Save victorjonsson/5e39e301f49fb845ed029cd0478847f6 to your computer and use it in GitHub Desktop.
This file contains 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
// Turn our form data into a JSON string | |
const data ={ | |
... | |
data: { | |
... | |
integrations: [ | |
{type: 'integrationX' ... }, | |
{type: 'integrationY' ... } | |
] | |
} | |
}; | |
const jsonString = JSON.stringify(data); | |
// Our files to upload | |
const jsonFile = new Blob([jsonString], {type: 'application/vnd.umeakommun.basicuse+json'}) | |
const fileUploadedByUser = document.querySelector('input[name="uploadFile"]'); | |
// Create a form containing our files | |
var form = new FormData(); | |
form.append('upload1', jsonFile, 'form.json'); | |
form.append('upload2', fileUploadedByUser); | |
// Send our form to server | |
axios({ | |
method: 'POST', | |
url: '/api/v1.0/send', | |
data: form, | |
config: { | |
headers: { | |
'Content-Type': 'multipart/form-data', | |
Authorization: 'Bearer ' + userAccessToken | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment