< BACK TO BLOG

Bulk post write on your blog - MyLogRoom.com

Published Sun Feb 21 2021



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 = 0i <=posts.length-1i++) {

    setTimeoutfunction (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(optionsfunction (errorresponse) {

            if (errorthrow new Error(error);

            console.log(response.body);

        });



    }, interval * ii);

}




Subscribe to my Newsletter

Get the latest posts delivered right to your inbox