using J1X JSON API server

James Peret 9 years ago
parent
commit
19f5a3f75d
2 changed files with 24 additions and 9 deletions
  1. 16 1
      app/scripts/app.js
  2. 8 8
      app/scripts/controllers/addPost.js

+ 16 - 1
app/scripts/app.js

@@ -25,7 +25,18 @@ angular
25 25
     'domainManagerApp.domainsList',
26 26
     'domainManagerApp.addPost'
27 27
   ])
28
-  .config(['$routeProvider', function($routeProvider) {
28
+
29
+  .config(['$routeProvider', '$httpProvider', function($routeProvider, $httpProvider) {
30
+
31
+    // Configs
32
+
33
+    //Enable cross domain calls
34
+    $httpProvider.defaults.useXDomain = true;
35
+
36
+    //Remove the header used to identify ajax call  that would prevent CORS from working
37
+    delete $httpProvider.defaults.headers.common['X-Requested-With'];
38
+
39
+    // Routes
29 40
     $routeProvider
30 41
       .when('/', {
31 42
         templateUrl: 'views/main.html',
@@ -47,3 +58,7 @@ angular
47 58
         redirectTo: '/'
48 59
       });
49 60
   }]);
61
+
62
+  app.config(function($httpProvider) {
63
+
64
+    });

+ 8 - 8
app/scripts/controllers/addPost.js

@@ -17,7 +17,7 @@
17 17
     $scope.whoisLookup = function() {
18 18
       // Whois domain lookup
19 19
       console.log("Whois lookup...");
20
-      var whoisUrl = 'http://api.who.pm/' + $scope.domain.name;
20
+      var whoisUrl = 'https://j1x-whois.herokuapp.com/lookup.json?url=' + $scope.domain.name;
21 21
       $http({
22 22
         method: 'GET',
23 23
         url: whoisUrl
@@ -77,25 +77,25 @@
77 77
       console.log(data);
78 78
       // Data: Registrar
79 79
       if(data.registrar != undefined){
80
-        $scope.domain.registrar = data.registrar[0];
80
+        $scope.domain.registrar = data.registrar;
81 81
       } else {
82 82
         $scope.domain.registrar = "";
83 83
       }
84 84
       // Data: Creation Date
85
-      if(data.creation_date != undefined) {
86
-        $scope.domain.registration_date = data.creation_date[0];
85
+      if(data.created_on != undefined) {
86
+        $scope.domain.registration_date = data.created_on;
87 87
       } else {
88 88
         $scope.domain.registration_date = "";
89 89
       }
90 90
       // Data: Expiration Date
91
-      if(data.expiration_date != undefined) {
92
-        $scope.domain.expiration_date = data.expiration_date[0];
91
+      if(data.expires_on != undefined) {
92
+        $scope.domain.expiration_date = data.expires_on;
93 93
       } else {
94 94
         $scope.domain.expiration_date = "";
95 95
       }
96 96
       // Data Owner
97
-      if(data.contacts != undefined) {
98
-        $scope.domain.owner = data.contacts.registrant.name;
97
+      if(data.owner != undefined) {
98
+        $scope.domain.owner = data.owner;
99 99
       } else {
100 100
         $scope.domain.owner = "";
101 101
       }