node.js - npm request module's formData is undefined in POST call to another Server + Express4.x.x -


var form = {                           widgetreleaseid: req.body.widgetreleaseid,             version: req.body.version,             uploaddate: req.body.uploaddate,                             myfiles : myfiles                          }; 

below npm request.

    request.post(             {                 url:target_url+'widget-releases/',                 formdata:form             }, function optionalcallback(err, httpresponse, body) {                  console.log('body'+body)                 if (err) {                     console.log(err)                 }                  del(['uploads/'+req.session.loginuser+'**/*'], function (err, paths) {                     console.log('deleted files/folders:\n', paths.join('\n'));                 });                 res.redirect('/admin-ui/widget-release/add');                }); 

api exposed 'post' on nodejs server. .error coming while reading files folder supposed created using multer. since req.body.widgetreleaseid 'undefined' ,it not creating folder copy files

router.post('/',multer({ dest: './public/api/downloads/',  changedest: function(dest, req, res) {       dest += req.body.widgetreleaseid;      var stat = null;     try {         stat = fs.statsync(dest);     } catch (err) {         mkdirp.sync(dest);     }     if (stat && !stat.isdirectory()) {         throw new error('directory cannot created because inode of different type exists @ "' + dest + '"');     }     return dest; }, rename: function(fieldname, filename, req,res){     return filename.replace(/\w+/g, '-'); }, onfileuploadstart: function (file, req, res) {     console.log(file.fieldname + ' starting ...') }, onfileuploadcomplete: function (file, req, res) {     console.log(file.fieldname + ' uploaded  ' + file.path) }   , onerror: function (error, next) {     console.log(error)     next(error) } }), function(req,res) {  //code goes here..      fs.readdir('./public/api/downloads/'+req.body.widgetreleaseid,function(err,files ){ .... }); 

body-parser settings correct , before routing. working few days getting error: enoent error there no data coming in formdata nodejs server. clue? had cleaned cache , update project well.


Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -