如何在Javascript HTTP请求中通过授权?

问题描述 投票:-1回答:1

我的JavaScript代码有什么错误?

function getAllLeads() {
    client.request.get("https://padmanabh.freshsales.io/api/leads/filters", {
        headers: {
            Authorization: "O5n0xfwgtg",
            "Content-Type": "application/json;charset=utf-8"
        }
    })
    .then(function () {
        console.error("Success");
        })
    .catch(function (error) {
        console.error(error);
    });
}

curl中类似的请求正在按如下方式工作,

curl -H "Authorization: Token token=O5n0xfwgtg" -H "Content-Type: application/json" -X GET "https://padmanabh.freshsales.io/api/leads/filters

((API_KEY已修改,请不要尝试)

javascript http authorization
1个回答
0
投票

根据您的问题所写的:

function getAllLeads() {
    client.request.get("https://padmanabh.freshsales.io/api/leads/filters", {
        headers: {
            Authorization:  = "O5n0xfwgtg",
            "Content-Type": "application/json;charset=utf-8"
        }
    })

授权:=“ O5n0xfwgtg”,缺少Token token =

您可能在这里找到答案:Basic Authentication Using JavaScript

© www.soinside.com 2019 - 2024. All rights reserved.