我編寫了一個節(jié)點應(yīng)用程序,它使用多個端點從 API 獲取數(shù)據(jù)。我也在使用代理來做到這一點。我目前正在使用socks-proxy-agent為我的實例創(chuàng)建一個 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, }, } )
未處理的承諾拒絕,即使我很確定我已經(jīng)處理了所有這些
慕尼黑5688855
2023-05-25 18:22:11