const posts = [
{
"title": "socket socket",
"text": "<p>Sockets can be so awesome taking socket project this summer!</p><p><a href=\"http://websocket.org/\" rel=\"noopener noreferrer nofollow\">http://websocket.org/</a></p><p><a href=\"https://helloenjoy.com/\" rel=\"noopener noreferrer nofollow\">https://helloenjoy.com/</a></p>",
"image": "",
},
{
"title": "nice blog in mongo",
"text": "<p><a href=\"https://www.janbasktraining.com/blog/mongodb-interview-questions/\" rel=\"noopener noreferrer nofollow\">https://www.janbasktraining.com/blog/mongodb-interview-questions/</a></p>",
"image": "",
},
]
var request = require('request');
var interval = 2 * 1000; // 10 seconds;
for (var i = 0; i <=posts.length-1; i++) {
setTimeout( function (i) {
const body = {};
body.title = posts[i].title
body.html = ( posts[i].text || posts[i].image) || ''
var options = {
'method': 'POST',
'url': 'https://app.mylogroom.com/api/post',
'headers': {
'Authorization': 'Bearer ggfgfsgadfaertefvasdfaerfaewfer',
},
body,
json:true
};
return request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
}, interval * i, i);
}