4

I'm trying to get a filtered record from loopback, but I don't understand why nodejs gives error on fallowing commands:

const https = require('https');
    var uid = '02644da038b37d7ba70b7ee1a92ba1d9';
        var URL = 'https://mobileapp.mydomain.com/api/uuids?filter[where][uuid]='+uid;
https.get(URL, (res) => {
  console.log('statusCode:', res.statusCode);
  console.log('headers:', res.headers);    
  res.on('data', (d) => {
    process.stdout.write(d);
  });

}).on('error', (e) => {
  console.error('ERROR:',e);
});

the error on output:

ERROR: { Error: getaddrinfo ENOTFOUND mobileapp.mydomain.com mobileapp.mydomain.com:443
    at errnoException (dns.js:28:10)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:79:26)
  code: 'ENOTFOUND',
  errno: 'ENOTFOUND',
  syscall: 'getaddrinfo',
  hostname: 'mobileapp.mydomain.com',
  host: 'mobileapp.mydomain.com',
  port: 443 }
RSA
  • 1,417
  • 4
  • 22
  • 37

3 Answers3

3

Obviously the domain you used is not valid.

A-yon Lee
  • 2,074
  • 2
  • 9
  • 18
  • when I put URL `https://mobileapp.mydomain.com/api/uuids?filter[where][uuid]=02644da038b37d7ba70b7ee1a92ba1d9` the result is a `json`. – RSA Oct 05 '17 at 06:26
  • 1
    Have a look at you `hosts` file, I think you're mis-pointing `mobileapp.mydomain.com` to a specific IP address, which can not be recognized on the internet. – A-yon Lee Oct 05 '17 at 06:47
  • Can I use request method? – RSA Oct 05 '17 at 07:11
  • 1
    I tried to `ping mobileapp.mydomain.com`, it cannot be recognized, see if your shell output something contains `[127.0.0.1]`? – A-yon Lee Oct 05 '17 at 07:18
  • I have static IP address of my domain and subdomain. I was using node 6.3.1 and upgrade to 8.5.0 and now looks ok. – RSA Oct 05 '17 at 07:29
3

URL shouldn't contain https:// modify url
from var URL = 'https://mobileapp.mydomain.com/api/uuids?filter[where][uuid]='+uid;
to var URL = 'mobileapp.mydomain.com/api/uuids?filter[where][uuid]='+uid;

I had this issue and this resolved it.

shary.sharath
  • 649
  • 2
  • 14
  • 29
  • It really helped me, The error was gone. ERROR: { Error: getaddrinfo ENOTFOUND mobileapp.mydomain.com mobileapp.mydomain.com:443 at errnoException (dns.js:28:10) at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:79:26) code: 'ENOTFOUND', errno: 'ENOTFOUND', syscall: 'getaddrinfo', hostname: 'mobileapp.mydomain.com', host: 'mobileapp.mydomain.com', port: 443 } – Imran Shaikh Mar 29 '23 at 10:04
1

probably it's because of SSL authentication in loopback, can you please try this npm package

Anouar Kacem
  • 635
  • 10
  • 24