I'm trying to perform multiple POST requests in my code however the POST request will only occur when the script terminates. So far I've loaded the below code in via a function and imported the function as a module with no success.
I'm relatively new to node.js so I may be missing something obvious here. Does anyone have any ideas?
var request = require('request');
var options = {
'method': 'POST',
'url': 'https://XXXXXXXXXX.com/Example',
'headers': {
'Authorization': 'Basic SuperSecretPassword',
'Content-Type': 'application/x-www-form-urlencoded'
},
form: {
'To': Receiver,
'From': Sender,
'Parameters': '{"Flag":"1","Duration":"5"}'
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
console.log(options);