خرید بک لینک

Vote count: 0

I'm having issues parsing more than one XML tag from the body of the response coming into my POST API. I can swap the placement of the text or affiliate tag within the request and the app always parses the top tag but not the other one. Any help is appreciated.

//Express
var app = express();
router.use(bodyParser.json());
router.use(xmlparser());

router.post('/api/v1/inboundData', function(req, res) {

var results = [];

// Grab data from http request
var data = {text: req.body.text, affiliate: req.body.affiliate};

// Get a Postgres client from the coection pool
pg.coect(coectionString, function(err, client, done) {
    // Handle coection errors
    if(err) {
      done();
      console.log(err);
      retu res.status(500).json({ success: false, data: err});
    }

    // SQL Query > Insert Data
    client.query("INSERT INTO "inboundData"("data", "affiliate") values($1, $2)", data.text, data.affiliate]);

    // SQL Query > Select Data
    var query = client.query("SELECT * FROM "inboundData" ORDER BY "ID" DESC");

    // Stream results back one row at a time
    query.on('row', function(row) {
        results.push(row);
    });

    // After all data is retued, close coection and retu results
    query.on('end', function() {
        done();
        retu res.json(results);
    });
});
});

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: پنجشنبه 19 فروردين 1395 ساعت: 23:16

صفحه بندی