|
@@ -42,27 +42,22 @@ exports.get = async (url, token = null) => {
|
|
|
* @returns {Promise<any>}
|
|
* @returns {Promise<any>}
|
|
|
*/
|
|
*/
|
|
|
exports.post = async (url, data, token= null, config = {}) => {
|
|
exports.post = async (url, data, token= null, config = {}) => {
|
|
|
- let response
|
|
|
|
|
- if (coba.decrypt(process.env.CXQSB) === PRODUCTION && token) {
|
|
|
|
|
- response = await axios.post(url, data,{
|
|
|
|
|
- headers: {
|
|
|
|
|
- Authorization: `Bearer ${token}`,
|
|
|
|
|
- Accept: 'application/json',
|
|
|
|
|
- ...config
|
|
|
|
|
- },
|
|
|
|
|
- })
|
|
|
|
|
- } else {
|
|
|
|
|
- let token = process.env.XNX1Q
|
|
|
|
|
- response = await axios.post(url, data, {
|
|
|
|
|
|
|
+ const httpsAgent = new https.Agent({
|
|
|
|
|
+ rejectUnauthorized: false,
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ const authToken =
|
|
|
|
|
+ coba.decrypt(process.env.CXQSB) === PRODUCTION && token
|
|
|
|
|
+ ? token
|
|
|
|
|
+ : coba.decrypt(process.env.XNX1Q)
|
|
|
|
|
+
|
|
|
|
|
+ response = await axios.post(url, data, {
|
|
|
headers: {
|
|
headers: {
|
|
|
- Authorization: `Bearer ${coba.decrypt(token)}`,
|
|
|
|
|
|
|
+ Authorization: `Bearer ${authToken}`,
|
|
|
Accept: 'application/json',
|
|
Accept: 'application/json',
|
|
|
- ...config
|
|
|
|
|
|
|
+ ...config,
|
|
|
},
|
|
},
|
|
|
- httpsAgent: new https.Agent({
|
|
|
|
|
- rejectUnauthorized: false
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ httpsAgent,
|
|
|
})
|
|
})
|
|
|
- }
|
|
|
|
|
return response.data
|
|
return response.data
|
|
|
}
|
|
}
|