javascript获取获取标头

时间:2018-04-01 00:20:07

标签: javascript api fetch

所以如果我使用这个网址,我会得到我正在寻找的回复:

https://od-api.oxforddictionaries.com:443/api/v1/entries/en/word

和这些标题:

Accept:application/json
app_id:vb805en4
app_key:bmd3a11b2951277c3a04ddbbnaec0216

但我的javascript fetch无效

const url = 'https://api.oxforddictionaries.com:443/api/v1/entries/en/'
let searchString = 'word'

fetch(url + searchString, {
  method: 'get',
  headers: {
    "Accept": "application/json",
    "app_id": "vb805en4",
    "app_key": "bmd3a11b2951277c3a04ddbbnaec0216"
  }
})  
  .then(function(response) {
    return response.json();
  })
  .then(function(myJson) {
    console.log(myJson);
  });

这是非工作的replit https://repl.it/@jasenmichael/oxford-fetch

0 个答案:

没有答案