const fsPromises = require("fs/promises");
const fs = require("fs");
import axios from "axios";
import * as https from "https";

const endPointQuery = async (url: string, data: any) => {
  let response: any = null;

  try {
    response = await axios.post(url, data);

    console.log(
      `TEST URL CLIENT POST ROUTE: ${url} | STATUS CODE: ${response.status}`
    );
  } catch (err: any) {
    if (err.response) {
      console.log("err.response: ", err.response);
    } else if (err.request) {
      console.log("err.request: ", err.request);
    } else {
      console.error(`Erro ao consultar endpoint ${url}: ${err}`);
    }
  }

  return response;
};

export default endPointQuery;
