亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

未處理的承諾拒絕,即使我很確定我已經處理了所有這些

未處理的承諾拒絕,即使我很確定我已經處理了所有這些

慕尼黑5688855 2023-05-25 18:22:11
我編寫了一個節點應用程序,它使用多個端點從 API 獲取數據。我也在使用代理來做到這一點。我目前正在使用socks-proxy-agent為我的實例創建一個 https 代理axios來使用代理。這是完成所有這些的類:export class Checker {    private region: Region    private proxy: AxiosProxyConfig | false    private client: AxiosInstance    constructor(region: Region, proxy?: AxiosProxyConfig | false) {        this.region = region;        this.proxy = proxy;        if (proxy) {            const proxyOptions = `socks://${proxy.host}:${proxy.port}`;            const httpsAgent = new SocksProxyAgent(proxyOptions);            this.client = axios.create({ timeout: 5000, httpsAgent: httpsAgent });        } else {            this.client = axios.create({ timeout: 5000 });        }    }    public check(account: Account): Promise<CheckResponse> {        return new Promise((resolve, reject) => {            this.client.post("xxx", {                acr_values: "urn:riot:bronze",                claims: "",                client_id: "riot-client",                nonce: 1,                redirect_uri: "http://localhost/redirect",                response_type: "token id_token",                scope: "openid link ban lol_region",            }).then((response) => {                const cookies = response.headers["set-cookie"];                this.client.put(                    "xxx",                    {                        type: "auth",                        username: account.username,                        password: account.password,                        remember: false,                        language: "en_GB",                        region: this.region.login,                    },                    {                        headers: {                            Cookie: cookies,                        },                    }                )
查看完整描述

1 回答

?
陪伴而非守候

TA貢獻1757條經驗 獲得超8個贊

當我查看您的代碼時,此 api 調用this.client.post("https://auth.riotgames.com/userinfo")沒有catch功能。通過在不同的函數中分離每個 api 調用并返回它們,您的代碼變得更加清晰,并且更容易找到這些錯誤。



查看完整回答
反對 回復 2023-05-25
  • 1 回答
  • 0 關注
  • 224 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號