Search code examples
node.jsstronglooploopbackjs

Loopback model listen/receive xml post


I developing loopback API and in one model called "payment" must listen xml post from another web app. I tried to make model hook on payment model to receive the xml post, but I confused how to accept xml file has been sent in my model hook?


Solution

  • LoopBack doesn't have built-in XML parsing at this point. But you can use an express route or middleware to handle the request, for example:

    app.use('/my-xml-middleware', function(req, res, next) {
       // transform xml to json
       next();
    });
    

    Or:

    app.post('/my-xml-service', function(req, res, next) {
      // process xml
      res.send(...);
    });