Node with axios or with async await

Posted about 3 years ago by morx05

Post a topic
Un Answered
m
morx05

Hi, how can i use zyte proxyRequest in node with axios ? or maybe use proxyRequest with async await?
Thanks.

0 Votes


1 Comments

P

Paulo Mesquita posted almost 3 years ago

This works for me:

    

const axios = require("axios");
const tunnel = require("tunnel");
const fs = require("fs");
const path = require("path");

async function makeRequest() {
  const options = {
    url: requestUrl,
    method: requestMethod,
    httpsAgent: tunnel.httpsOverHttp({
      ca: [fs.readFileSync(path.resolve(__dirname, "pathToCertificate/yourCertificate.crt"))], // You can download this from zyte API access tutorial
      proxy: {
        host: proxyHost,
        port: proxyPort,
        proxyAuth: `${proxyAPIKey}:`,
      },
    }),
  };
  const axiosResponse = await axios.request(options);
  console.log(axiosResponse);
}

  

1 Votes

Login to post a comment