V
V
ViktorPortos2017-03-13 21:30:27
Node.js
ViktorPortos, 2017-03-13 21:30:27

Does NODE.JS need to POST a request, wait for a response, and everything needs to be done with Fibers in a loop?

Good time everyone!
In node.js, as in js, a beginner.
You need to make a request to the https service in the post cycle, wait for a response and put this response in the subd.
There is the following code

var f = Fiber(function(t) {
var fiber = Fiber.current;
                var resp = httpsclient.post({
            headers: {'content-type' : 'text/html'},
            url:     'myurl',
            body:    t.body
          }, function handle_callback(error, response, body) {		
              //console.log('<BODY>' + body);
              if (!error) {console.log( 'row_id calculated'); }
              else 
                  {console.log('<ERROR>' + e);}
          });
        Fiber.yield(resp);
      });
      var lbody = f.run(my.t);

I get the same value that I insert into the post request.
Correct plz.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question