Propublica API使用JavaScript验证密钥 [英] Propublica API authenticate key with javascript
本文介绍了Propublica API使用JavaScript验证密钥的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
很抱歉,如果这是一个简单的问题,但我正在尝试将GET请求发送到
Sorry if this is a simple question, but I'm trying to send a GET request to the ProPublica API. They gave me a key, but the documentation does not say how to authenticate with this key when I try and hit the endpoints of the API. If anyone can make sense of this, I'd appreciate it!
我想打这条路线:
GET https://api.propublica.org/congress/v1/members/{chamber}/{state}/current.json
文档仅提及curl:
curl "https://api.propublica.org/congress/v1/members/senate/RI/current.json"
-H "X-API-Key: PROPUBLICA_API_KEY"
推荐答案
感谢Amol的答复,这里是可写入控制台的有效版本.确保您拥有jQuery,或在具有jQuery的网站上的浏览器开发工具中对其进行测试.
Thanks to Amol for the reply, here is a working version that writes to the console. Make sure you have jQuery, or test it in a browser's dev tools on a site that has jQuery.
$.ajax({
url: "https://api.propublica.org/congress/v1/members/senate/RI/current.json",
type: "GET",
dataType: 'json',
headers: {'X-API-Key': 'YOUR KEY HERE'}
}).done(function(data){
console.log(data)
});
这篇关于Propublica API使用JavaScript验证密钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文