Thursday, 16 March 2017

Http request with node.js

I wrote simple http request but I don't know how to send data to index.html. Could you help me ?

 http.get({
    hostname: 'simsms.org',
    path: `/priemnik.php?metod=get_balance&service=opt4&id=&apikey=***`
    }, (res) => {
    var body = '';
    res.on('data', function (d) {
        body += d;
    });
    res.on('end', function () {
        try {
            data = JSON.parse(body);
           console.log(data);

        } catch (err) {
            console.log(err);
        }
    });
});



via Gökhan Namal

No comments:

Post a Comment