GetSources API REST example

In this example below you will see how to do a GetSources API REST example with some HTML / CSS and Javascript

Thumbnail
This awesome code was written by fpape, you can see more from this user in the personal repository.
You can find the original code on Codepen.io
Copyright fpape ©
  • HTML
  • CSS
  • JavaScript
    
<head>
<script type="text/javascript" src="https://code.jquery.com/jquery-3.1.1.min.js
"></script>
 
</head>


/*Downloaded from https://www.codeseek.co/fpape/getsources-api-rest-example-YGJpoz */
    


/*Downloaded from https://www.codeseek.co/fpape/getsources-api-rest-example-YGJpoz */
    var link="http://arpa-er.geodab.eu/gi-cat-arpa/services/api-rest/";
//$.ajax({
//        type: "GET",
//        url: link+"sources",
//        dataType: "json",
//        success: function (data) {
//            if (data) {
//               alert(JSON.stringify(data));
//            }
//        },
//        error: function(xhr, ajaxOptions, thrownError){
//            alert("ERRORE");
//            //alert(xhr.status);
//            alert(xhr.responseText);
//        }
//    });

var post = '{"where":{},"when":{},"what":"","who":[],"sources":[],"searchId":"","start":1,"pageSize":5,"timeout":10000,"searchFields":"title,keyword","spatialRelation":"CONTAINS","termFrequency":"keyword,format,protocol,source","extensionRelation":""}';

$.ajax({
        type: "GET",
        url: link+"sources",
        dataType: "json",
        contentType:"application/json",
         success: function (data) {
            if (data) {
               alert(JSON.stringify(data));
            }
        },
        error: function(xhr, ajaxOptions, thrownError){
            alert("ERRORE");
            //alert(xhr.status);
            alert(xhr.responseText);
        }
    });

Comments