Start a new topic

Node with axios or with async await

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

1 Comment

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 person likes this
Login to post a comment