weixin_33717117 2016-09-22 10:08 采纳率: 0%
浏览 158

简单的d3.json调用失败

How can this possibly fail?

d3.json("https://api.kraken.com/0/public/Time",
   function(){
      console.log(arguments);
   });

I'm getting The ole' CORS XMLHttpRequest cannot load https://api.kraken.com/0/public/Time/. No 'Access-Control-Allow-Origin' header is present on the requested resource., however, I can successfully make calls to https://api.kraken.com/0/public/Ticker without any issues.

I've spent an embarrassingly amount of time already.

EDIT:

This works for /Ticker:

var myurl = "https://api.kraken.com/0/public/Trades";
var data = "pair=ETHXBT";
var r = d3.json(myurl).header("content-type", "application/x-www-form-urlencoded").post(data, function(error, response){console.log(arguments);});

This __does not work_ for /Trades (again, 'Access-Control-Allow-Origin' error):

var myurl = "https://api.kraken.com/0/public/Trades";
var data = "pair=ETHXBT";
var r = d3.json(myurl).header("content-type", "application/x-www-form-urlencoded").post(data, function(error, response){console.log(arguments);});

Here's the Kraken API description: https://www.kraken.com/help/api

So far my biggest conclusion is that I'm stupid, but I need your help to determine just how stupid.

  • 写回答

1条回答 默认 最新

  • weixin_33709590 2016-09-23 16:53
    关注

    Just got this from Kraken's support team:

    Hi,

    Thank you very much for reaching out to us. Only ticker allows CORS. Please let us know if you have any further questions!

    Warm Regards,

    ...

    评论

报告相同问题?