mirror of
https://github.com/curlconverter/curlconverter.git
synced 2022-05-22 02:35:29 +03:00
* axios.post .put .patch take data as the 2nd arg * rename formData to form * add warning about data not being sent * sort imports properly * passing an object as data sends it as json, not urlencoded
20 lines
534 B
JavaScript
Generated
20 lines
534 B
JavaScript
Generated
const axios = require('axios');
|
|
const FormData = require('form-data');
|
|
const fs = require('fs');
|
|
|
|
const form = new FormData();
|
|
form.append('attributes', '{"name":"tigers.jpeg", "parent":{"id":"11446498"}}');
|
|
form.append('file', fs.readFileSync('myfile.jpg'), 'myfile.jpg');
|
|
|
|
const response = await axios.post(
|
|
'https://localhost:28139/api/2.0/files/content',
|
|
form,
|
|
{
|
|
headers: {
|
|
...form.getHeaders(),
|
|
'Authorization': 'Bearer ACCESS_TOKEN',
|
|
'X-Nice': 'Header'
|
|
}
|
|
}
|
|
);
|