Propublica API使用javascript验证密钥

Propublica API使用javascript验证密钥,javascript,api,authentication,key,endpoint,Javascript,Api,Authentication,Key,Endpoint,如果这是一个简单的问题,很抱歉,但我正在尝试向发送GET请求。他们给了我一个密钥,但文档没有说明当我尝试访问API的端点时如何使用该密钥进行身份验证。如果有人能理解这一点,我将不胜感激 我想走这条路线: GET https://api.propublica.org/congress/v1/members/{chamber}/{state}/current.json 本文件仅提及: curl "https://api.propublica.org/congress/v1/members/sena

如果这是一个简单的问题,很抱歉,但我正在尝试向发送GET请求。他们给了我一个密钥,但文档没有说明当我尝试访问API的端点时如何使用该密钥进行身份验证。如果有人能理解这一点,我将不胜感激

我想走这条路线:

GET https://api.propublica.org/congress/v1/members/{chamber}/{state}/current.json
本文件仅提及:

curl "https://api.propublica.org/congress/v1/members/senate/RI/current.json"
  -H "X-API-Key: PROPUBLICA_API_KEY"
试着用这个

$.ajax({
         url: "http://localhost/PlatformPortal/Buyers/Account/SignIn",
         type: "GET",
         dataType: 'json',
         headers: {'X-API-Key', 'PROPUBLICA_API_KEY'}
       });
试着用这个

$.ajax({
         url: "http://localhost/PlatformPortal/Buyers/Account/SignIn",
         type: "GET",
         dataType: 'json',
         headers: {'X-API-Key', 'PROPUBLICA_API_KEY'}
       });

感谢Amol的回复,这里有一个可以写入控制台的工作版本。确保您有jQuery,或者在具有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)
       });

感谢Amol的回复,这里有一个可以写入控制台的工作版本。确保您有jQuery,或者在具有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)
       });

非常感谢你!我会稍微修改一下这篇文章,因为它不是逗号,而是冒号。你真棒!非常感谢你!我会稍微修改一下这篇文章,因为它不是逗号,而是冒号。你真棒!