对于这个API,我可以使用jquery的ajax方法而不是unirest吗?

以下是我正在尝试使用的API的说明。它推荐unirest,但是我不能在我的服务器上安装node。

https://www.wordsapi.com/docs/?javascript#

这是我尝试使用的代码:

$(document).ready(function() {
    $.ajax({
        url: "https://wordsapiv1.p.mashape.com/words/soliloquy",
        type: "GET",
        datatype: "json",
        crossDomain: "true",
        contentType: "application/json; charset=utf-8",
        headers: {"X-Mashape-Key": "XXXXXXX"},
        success: function(result) {
            alert("SUCCESS!");
        },
        error: function(result) {
            alert("FAIL!");
        }
    });
});

但是我得到了一个401未授权的请求结果。X-Mashape-Key头包含在带有api密钥的调用中,但它似乎不想接受它。unirest是否做了此jquery ajax调用不能做的事情?

转载请注明出处:http://www.lsql.net/article/20230501/2448747.html