Extract data with API / JSON

0

My query is as follows, I have a rest API this is the url ( link ) and what I want is to make a GET with a Json .

Search the internet for examples with curl but I have never worked with that extension and I do not know if it goes in an html, I tried it and it clearly did not work, and in fact what I got was something worse:

My code is the following one, apparently at least I connected with the page, but it says to me:

  

No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. The response had HTTP status code 405.

What for now I understand that I do not have access to the api key. and the apikey is next, and I do not know where to add it.

  

102dc83bab93384369df4a6768f2fd9d

This is my code

HTML:

<!DOCTYPE html>
<html lang="es-ES">  
  <head>
    <meta charset="utf-8" />
<title>JSON</title>


</head>
<body>
<div id="summary"></div>

<button id="load-more" style="margin: 150px;" class="btn btn-color-2"> <i class="fa fa-refresh"></i>Cargar</button>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script src="js/prueba.js"></script>    
</body>
</html>

JS:

$('#load-more').click(function(){
            $.ajax({
                    url:'https://app.relojcontrol.com/api/consultaTurnos/consulta',
                    type:'GET',
                    dataType:'json',
            })
            .done(function(data){
                    console.log( data );
            })
            .fail(function(){alert("Fallo la carga");})
    });

Thank you in advance.

    
asked by Javier Alvarado Veas 27.08.2018 в 22:19
source

1 answer

0

For now change a couple of things in the JScript and achieve at least to show me a part of the query, although not yet the data, within the document there are several "codeResponse" and the -3 (Query Error) must be to which it makes the request but since it still does not apply the Api key launches that answer.

At least I already showed the "AssignmentTurn Employee: which is the format of the data output as in the document, but I still do not know how to take and apply the api-key: 102dc83bab93384369df4a6768f2fd9d

The JScript is like this now:

JS:

$('#load-more').click(function(){
            $.ajax({
                    url:'https://app.relojcontrol.com/api/consultaTurnos/consulta',
                    type:'POST',
                    dataType:'json',
            })
            .done(function(result){
                    console.log( result );
            })
            .fail(function(){alert("Fallo la carga");})
    });

Look for the BackEnd but do not get any explanation in Spanish of the or some example code.

If you could give me one here, I would be grateful and make it clear to help the problem. Thank you all.

    
answered by 29.08.2018 в 20:57