NodeJS, Axios – post file from local server to another server
The 2 oldest answers did not work for me. This, however, did the trick: const FormData = require(‘form-data’); // npm install –save form-data const form = new FormData(); form.append(‘file’, fs.createReadStream(file.path)); const request_config = { headers: { ‘Authorization’: `Bearer ${access_token}`, …form.getHeaders() } }; return axios.post(url, form, request_config); form.getHeaders() returns an Object with the content-type as well … Read more