I am trying to parse individual fields within a form and can't seem to find an example for this. I am able to get the response with the browser, but the console isn't printing the specific field.
Below is my code...
form.parse(req, function(err, fields, files) {
console.log('Field 1: ' + fields[0]);
res.writeHead(200, {'content-type': 'text/plain'});
res.write('received upload:\n\n');
res.end(util.inspect({fields: fields, files: files}));
});
When using the above code, console.log prints "undefined" for fields[0]. The name of this field from my form is "itemName" and is just a text field. Typically using the BodyParser you could get this using "req.body.itemName" but how would I get this same thing in Formidable?
Since this comes back as a JSON response, an example to get the "name" of a file could be the following:
console.log(files.file.name);
So to get a field name should work similar:
console.log(fields.field.name);