Browse Source

Refactor axios post method to reuse https agent configuration

yazid138 1 month ago
parent
commit
f7e740fb3f
1 changed files with 5 additions and 1 deletions
  1. 5 1
      utils/axios.js

+ 5 - 1
utils/axios.js

@@ -43,13 +43,17 @@ exports.get = async (url, token = null) => {
  */
  */
 exports.post = async (url, data, token= null, config = {}) => {
 exports.post = async (url, data, token= null, config = {}) => {
   let response
   let response
+  const agent = new https.Agent({
+    rejectUnauthorized: false,
+  })
   if (coba.decrypt(process.env.CXQSB) === PRODUCTION && token) {
   if (coba.decrypt(process.env.CXQSB) === PRODUCTION && token) {
     response = await axios.post(url, data,{
     response = await axios.post(url, data,{
       headers: {
       headers: {
         Authorization: `Bearer ${token}`,
         Authorization: `Bearer ${token}`,
         Accept: 'application/json',
         Accept: 'application/json',
         ...config
         ...config
-      }
+      },
+      httpsAgent: agent
     })
     })
   } else {
   } else {
     let token = process.env.XNX1Q
     let token = process.env.XNX1Q