How to run curl command using node js

Published on Author Code Father

curl -X POST -H “Content-Type: application/json” -d ‘{
“setting_type”:”greeting”, “greeting”:{ “text”:”Timeless apparel for the masses.” } }’ “https://graph.facebook.com/v2.6/me/thread_settings?access_token=PAGE_ACCESS_TOKEN

How to run this above command using node.js or Is there any other process to run this?

var exec = require('child_process').exec;
exec('curl -X POST -H "Content-Type: application/json" -d \'{ "setting_type":"greeting", "greeting":{ "text":"Timeless apparel for the masses." } }\' "https://graph.facebook.com/v2.6/me/thread_settings?access_token=PAGE_ACCESS_TOKEN"', function(error, stdout, stderr) {
    console.log('stdout: ' + stdout);
    console.log('stderr: ' + stderr);
    if (error !== null) {
        console.log('exec error: ' + error);
    }

Comments

comments