0
function foo() {
  return fetch('https://central.wordcamp.org/wp-json/wp/v2/wordcamps');
}

function* main() {
  try {
    var text = yield foo();
    var d = text.json();
    console.log(d); //Promise {<pending>} 
  } catch (err) {
    console.error(err);
  }
}
var it = main();

var p = it.next().value;

// wait for the `p` promise to resolve
p.then(function (text) { 
    it.next(text);
  },
  function (err) {
    it.throw(err);
  }
);

promise result ok but in console Promise {<pending>}

SCREEN SHOT Anybody can help me where the problem. BOOK REFERNCE

you can check helping detail in this book search Generators + Promises.

anoop
  • 3,229
  • 23
  • 35
  • 1
    First of all, stop using generators with a promise runner as a lame fill-in for `async`/`await`! – Bergi Apr 08 '18 at 19:39
  • This is expected. [`text.json()` does return another promise](https://stackoverflow.com/q/37555031/1048572). – Bergi Apr 08 '18 at 19:41

0 Answers0