Results 1 to 1 of 1

Thread: [eng](problem) get API data using JavaScript[/eng]-[pt-br](problema) obter da[/pt-br]

  1. #1
    Fresh Spawn
    Join Date
    Sep 2017
    Posts
    1

    [eng](problem) get API data using JavaScript[/eng]-[pt-br](problema) obter da[/pt-br]

    [eng]
    I'm reading the API documentation. and I ended up doing some tests ..
    In PHP, I was able to consume the API quietly!
    Already using JavaScript I had some basic CORS issues.

    Attachment 205186

    One solution I know would be to use proxy
    example: "https://cors-anywhere.herokuapp.com/"
    but the remote address would not be the same anymore!
    When I use this proxy example, my connection is declined and I receive the following message >> {"reason": "badRequest", "message": "Origin not allowed"}

    wanted to hear from the API developers team
    if there is a possibility of putting a header ('Access-Control-Allow-Origin: *') at the beginning of the API pages.

    with this I believe it would solve the problem to consume the API via AJAX

    Taking advantage of the topic, is there any way to consume the API currently with AJAX in JavaScript?
    if so, could you post an example?
    [/eng]




    [pt-br]
    estou lendo a documentação da API. e acabei fazendo uns testes..
    Em PHP, eu consegui consumir a API tranquilamente!
    Já usando JavaScript eu tive uns problemas basicos de CORS.

    Attachment 205186

    Uma solução que conheço seria usar proxy
    exemplo: "https://cors-anywhere.herokuapp.com/"
    porem o endereço remoto não seria mais o mesmo!
    quando uso esse exemplo de proxy, a minha conexão e recusada e recebo a seguinte mensagem >> {"reason":"badRequest","message":"Origin not allowed"}



    queria saber da equipe de desenvolvedores da API
    se há uma possibilidade de colocarem um header('Access-Control-Allow-Origin: *') no começo das paginas de API.

    com isso acredito que resolveria o problema pra consumir a API via AJAX

    Aproveitando o topico, há alguma forma de consumir a API atualmente com AJAX em JavaScript?
    se sim poderiam postar um exemplo?
    [/pt-br]


    code >> https://gist.github.com/DerexScript/...f00fd118e2ca00
    Last edited by DScript; September 7th, 2017 at 04:41 AM.

Similar Threads

  1. [Android] Problem with the shop help/ problema con tienda
    By redarcangel in forum Bugs & Problems
    Replies: 1
    Last Post: August 30th, 2017, 05:18 AM
  2. [Android] Problema en los cuarteles / Problem in barracks
    By Ferwall in forum Bugs & Problems
    Replies: 0
    Last Post: June 3rd, 2017, 01:39 PM
  3. Javascript API
    By carlsb3rg in forum Ideas & Feature Requests
    Replies: 0
    Last Post: April 11th, 2014, 08:14 AM
  4. Loot Problem (with data)
    By HansClashOfClans in forum General
    Replies: 77
    Last Post: March 18th, 2014, 01:44 PM
  5. Problema com busca de clãs / Problem with search clans
    By GabrielXavier in forum Bugs & Problems
    Replies: 2
    Last Post: January 16th, 2014, 03:19 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •