Gistrec

NodeJS axios proxy

Sep 24th, 2020
216
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const axios = require('axios-https-proxy-fix');
  2.  
  3. const request = async function(url, proxy) {
  4.     try {
  5.         const response = await axios.get(url, {
  6.             proxy: {
  7.                 host: proxy.ip,
  8.                 port: proxy.port,
  9.                 auth: {
  10.                     username: proxy.login,
  11.                     password: proxy.password
  12.                 }
  13.             }
  14.         });
  15.  
  16.         return response.data;
  17.     }catch (error) {
  18.         console.error('Ошибка в axios запросе', error);
  19.         return null;
  20.     }
  21. }
  22.  
Comments
  • User was banned
Add Comment
Please, Sign In to add comment