Saturday 1 April 2017

node.js needle post not doing its job

Why doesn't Needle do its job here? It just seems to hang forever waiting to time out. Eventually I will get the

Ready-o, friend-o

var express = require('express');
var router = express.Router();
var needle = require('needle');

router.get('/', function (req, resp) {
    console.log("nee.get");

    var data = { key: 'value' };
    needle.post('http://localhost/nee', data, { json: true })
        .on('done', function () {
            console.log('Ready-o, friend-o.');
            resp.sendStatus(200);
        })
});


router.post('/', function (req, resp, next) {
    console.log(req.body.key);
    res.sendStatus(200);
});


module.exports = router;



via Steve

No comments:

Post a Comment