首页 > 解决方案 > 标头中不包含授权标头

问题描述

我正在尝试向 oxford dictionary api 发送请求,但我无法传递自动标头。

这是我写的函数

function testResults (form) {
    var TestVar = form.inputbox.value;
    alert ("You typed: " + TestVar);

var url='https://od-api.oxforddictionaries.com:443/api/v1/';
url = url+"?word_id="+encodeURIComponent(TestVar);


    word=fetch(url, {
        method: 'GET',
        mode: 'no-cors',
        headers: new Headers({
            'app_id': 'id',
            'app_key': 'key'

        })
    })
    word.then(function(response){
        console.log(response)
        return response.json();
    }).then(function(resJson){
        console.log(resJson);
    })
}

我在通过的开发人员工具中看不到它,并且收到 403 响应,

标签: javascriptecmascript-6

解决方案


我猜你必须在 URL 参数(查询参数)中发送它们,而不是标题

更新 我用 Postman 应用程序尝试过。标题为我工作

在此处输入图像描述


推荐阅读