criso / fbgraph

NodeJs module to access the facebook graph api
http://criso.github.io/fbgraph/
1.09k stars 174 forks source link

AWAIT #123

Closed KitsuneDev closed 1 year ago

KitsuneDev commented 7 years ago

Hey guys, sorry, I'm new to NodeJS. Is there any way to await for a post call??

Twisterking commented 7 years ago

use bluebird to "promisify" the graph calls and use Promises instead of callbacks!

juanarbol commented 7 years ago

Or using Async await functions

ffflabs commented 6 years ago

Like @Twisterking said, use bluebird to promisify fbgraph, then all methods will have their promisified async method with the Async suffix:

const Promise = require('bluebird'),
  graph = Promise.promisifyAll(require('fbgraph'));

graph.setVersion('2.11');
graph.setOptions({...some options...});

async function getFeed(page_id) {
   const feed = await graph.getAsync(`/${page_id}/feed`);
}
CKanishka commented 4 years ago

Thanks @ffflabs your solution helped a lot.