sanjeev-rajput opened a new issue, #1251:
URL: https://github.com/apache/royale-asjs/issues/1251

   HTTPService works great while loading data, a demo example is also available 
on royale website which is very helpful.
   
   it is clearly mentioned that this call can be used for 'GET' 'POST' 'PUT' 
and 'DELETE' methods.  I am stuck 'POST' while working on nodeJS API call as I 
am unable to send some data to nodeJS file. 
   
   when submit nodeJS receives nothing under req object. can someone please 
write small example for 'POST' method. just send some temp string.
                                          
                                           var svr:HTTPService = new 
HTTPService();
                                           svr.method = HTTPConstants.POST;
                                        var fd:FormData = new FormData();
                                        
fd.append('file',ufile.royale_wrapper._element.files[0]);
                                        fd.append('contentType' , 'text/plain');
                                        svr.url = 
"http://localhost:3001/FileUpload/upload";;
                                        
svr.addEventListener(HTTPConstants.COMPLETE, callbackFunc)
                                        svr.contentData = fd;
                                        svr.send();
   
   
   nodejs
   
   const express = require('express');
   const multer = require('multer');
   const path = require('path');
   const FileUpload = express();
   const upload = multer({ dest: 'uploads/' }); // Destination folder for 
uploaded files
   FileUpload.post('/upload', upload.single('file'), (req, res) => {
       console.log(req.body)
       if (!req.file) {
           return res.status(400).send('No file uploaded.');
       }
       res.send(`File uploaded successfully: ${req.file.originalname}`);
   });
   module.exports = FileUpload;
   
   
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to