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.” } }’ “

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." } }\' ""', function(error, stdout, stderr) {
    console.log('stdout: ' + stdout);
    console.log('stderr: ' + stderr);
    if (error !== null) {
        console.log('exec error: ' + error);