Value in append(field, value, options) is set to null
See original GitHub issueI am trying to associate a filename with a JSON object and post a multipart request. I don’t know why I am getting this error. Options is set and value is just a JSON string. Reproducible test program is included here.
node_modules\form-data\lib\form_data.js:226 } else if (options.filename || value.name || value.path) {
TypeError: Cannot read property ‘name’ of null
const request = require('request');
const FormData = require('form-data');
var options = {
filename: 'test.json',
contentType: 'application/json'
};
var json = {
text: 'hello world'
};
var form = new FormData();
form.append('file', JSON.stringify(json), options);
console.log(JSON.stringify(form, null, 2));
var username = 'username',
password = 'password',
url = 'https://' + username + ':' + password + '@somewhere.com';
request.post({
url: url,
formData: form
},
function optionalCallback(err, httpResponse, body) {
if (err) {
return console.error('upload failed:', err);
}
console.log('Upload successful! Server responded with:', body);
}
);
Issue Analytics
- State:
- Created 5 years ago
- Reactions:4
- Comments:7
Top Results From Across the Web
JQuery append value set null before setting another
Here I'm doing is split value in the href and set that value to modal-header . Then I again do that it shows...
Read more >Append (Data Management)—ArcGIS Pro | Documentation
ArcGIS geoprocessing tool that appends multiple input datasets into an existing target dataset.
Read more >Modifying table schemas | BigQuery - Google Cloud
When you add new columns during an append operation, the values in the new columns are set to NULL for existing rows. To...
Read more >How To: Replace null values with zeroes in an attribute table ...
Loop through the fields, and determine the count for the values. for field in fieldObs: fieldNames.append(field.name) del fieldObs fieldCount = ...
Read more >Add, select, or clear items | Select2 - The jQuery replacement ...
Set the value, creating a new option if necessary if ... by default var newOption = new Option(data.text, data.id, true, true); // Append...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank you for the clarification, @aacotroneo!
The example from
form-data
confused me.if it’s not clear… you don’t require(‘form-data’) in your code… you require(‘request’) which uses form-data internally… and you just pass an plain js object.