1

I'm trying to get image url, and then post it somehow(either with FormData)... I've found some usefull info here 1, 2, 3 ... I've tried several variants of code. but still cant' load image to server. My code now :

var FormData = require('form-data');
var request = require('request');

      var form = new FormData();
         request.get(url, {encoding:null}, function (error, response, body) {

             form.append('my_logo', body);
             form.getLength(function(err,length){
                 console.log(length);
                 var r = request.post(upload_url, { headers: { 'content-length': length } }, function(err, httpResponse, body) {

                     if (err) console.log(+err)
                         var res = (typeof body == 'string') ? JSON.parse(body) : body;
                     console.log(res);

                 })
                 r._form = form
             });
         })

in response from Post request i receive information, that loaded undefined... I use request and form-data library... How could i do that right? Maybe with native node.js code it will be better?

Community
  • 1
  • 1
illdo
  • 41
  • 1
  • 7

0 Answers0