Thursday, 18 May 2017

DNS Not found node request

I am trying to hit my api with the following code. It returns

{ Error: getaddrinfo ENOTFOUND my.url.com my.url.com:443
0|www      |     at errnoException (dns.js:28:10)
0|www      |     at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:73:26)
0|www      |   code: 'ENOTFOUND',
0|www      |   errno: 'ENOTFOUND',
0|www      |   syscall: 'getaddrinfo',
0|www      |   hostname: 'my.url.com',
0|www      |   host: 'my.url.com',
0|www      |   port: 443 }
0|www      | POST /buy/?product=bundle 200 38.541 ms - -

Meanwhile, I ran dns.lookup(my.url.com, console.log) in the console and it returned this:

 dns.lookup("shop.domeha.com", console.log)
GetAddrInfoReqWrap {
  callback: { [Function: asyncCallback] immediately: true },
  family: 0,
  hostname: 'shop.domeha.com',
  oncomplete: [Function: onlookup],
  domain: 
   Domain {
     domain: null,
     _events: { error: [Function: debugDomainError] },
     _eventsCount: 1,
     _maxListeners: undefined,
     members: [] } }
> null '104.25.241.111' 4

So, I'm not sure what's going on. I copied one of my other routes verbatim and then modified it. Does having a subdomain have anything to do with it? Using postman, I am able to hit the api fine.

Code:

router.post('/buy/', function (req, res) {
        let product = req.query.product;

        if (product == 'bundle' ) {
          product = 1;
        }

        console.log(product)


        var options = { method: 'POST',
        url: 'https://myurl.com/api/orders.json',
        headers:
         { 'content-type': 'application/json','X-Spree-Token': '######'},
        body: {
            "order": {
              "line_items": [
                { "variant_id": product, "quantity": 1 }
              ]
            }
          },
        json:true
      };

      request(options, function (error, response, body) {
        if (error) console.log(error)
        res.json(body)
      });
    }); //router post



via QueSo

No comments:

Post a Comment