gpt4 book ai didi

javascript - 在 javascript 中返回特定的 header

转载 作者:行者123 更新时间:2023-11-30 06:18:40 25 4
gpt4 key购买 nike

我正在尝试通过 javascript 代码段从我的 discord 帐户返回授权 key 。以前我如何获得 token 是通过打开 chrome 开发人员工具转到“api/v6”中的网络类型重新加载页面选择“库”然后单击标题并向下滚动它会显示 token :( token )。

我尝试用 javascript 返回它,但我似乎没有得到我需要的返回值

var req = new XMLHttpRequest();
req.open('GET', document.location, false);
req.send(null);
var headers = req.getAllResponseHeaders('library').toLowerCase();
alert(headers);

我希望得到类似的东西

 :authority: discordapp.com
:method: GET
:path: /api/v6/users/@me/library
:scheme: https
accept: */*
accept-encoding: gzip, deflate, br
accept-language: nl
authorization: (token)

相反,我被退回了

date: wed, 13 feb 2019 10:58:38 gmt
content-encoding: br
server: gws
x-frame-options: sameorigin
content-type: text/html; charset=utf-8
status: 200
cache-control: private
alt-svc: quic=":443"; ma=2592000; v="44,43,39"
x-xss-protection: 1; mode=block
expires: wed, 13 feb 2019 10:58:38 gmt

最佳答案

getAllResponseHeaders 返回所有 header 。您需要方法 getResponseHeader 来获取特定的 header 。

所以你的代码会变成:

var headers = req.getResponseHeader('library').toLowerCase();

参见 documentation here .

关于javascript - 在 javascript 中返回特定的 header ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54668435/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com