خرید بک لینک

Vote count: 0

I am a little confused by the difference between asynchronous/synchronous. A little background, I am trying to write a program that is using callbacks and promises. I was trying to create nested requests, but the value of the object is not carrying through those requests, so I am creating a function that takes input a JS object, modifies it, and retus back the js object. The modification would include an API call that looks for another field to add to the JS object.

Can I accomplish this by something similar to this:

  TEST1 function(....){
        // do stuff
        request.get(options, function(error, response, body) {
                  // do stuff to get js object
                  jsobject = objectModification(jsobject); //modified js object
       });
  }

  objectModification function(jsobject) {
        request.get(options, function(error, response, body) {
                  // do stuff to modify js object
       });
        retu jsobject;
  }      

asked 42 secs ago

- - , .
.

برچسب: نویسنده: استخدام کار تاريخ: چهارشنبه 23 تير 1395 ساعت: 7:41

صفحه بندی