Using Node.js to connect to a REST API

后端 未结 4 714
借酒劲吻你
借酒劲吻你 2020-12-13 16:15

Is it sensible to use Node.js to write a stand alone app that will connect two REST API\'s?

One end will be a POS - Point of sale - system

The other will be

4条回答
  •  渐次进展
    2020-12-13 16:57

    A more easy and useful tool is just using an API like Unirest; URest is a package in NPM that is just too easy to use jus like

     app.get('/any-route', function(req, res){
         unirest.get("https://rest.url.to.consume/param1/paramN")
           .header("Any-Key", "XXXXXXXXXXXXXXXXXX")
           .header("Accept", "text/plain")
           .end(function (result) {
           res.render('name-of-the-page-according-to-your-engine', {
             layout: 'some-layout-if-you-want',
             markup:  result.body.any-property,
        });
    

    });

提交回复
热议问题