Monday, 13 March 2017

how to parse" http GET request"'s text response in nodejs?

I make a HTTP GET request to Facebook to have a long live token , as a response I have a plain text with the access token and expiration date , but I don't know how to parse it.

request.get('https://graph.facebook.com/oauth/access_token?client_id=' + APP_ID + '&client_secret=' + APP_SECRET + '&grant_type=fb_exchange_token&fb_exchange_token=' + CURRENT_ACCESS_TOKEN)
    .on('data', function(data) {
        console.log("body= " + data); 
    });

res.render('SocialMedia.ejs');

I tried data.access_token but it's undefined



via Sam

No comments:

Post a Comment