Update funtions.js

This commit is contained in:
Marcelo Sanchez 2025-12-15 11:56:08 -05:00
parent 93391f8f3c
commit cc90b67b4d

View File

@ -2,6 +2,7 @@ const { error } = require('actions-on-google/dist/common');
const axios = require('axios');
const URLIC = 'https://sistemasic.manta.gob.ec/';
const URLPC = 'https://portalciudadano.manta.gob.ec/';
const API_TOKEN_PORTAL = 'de135b313b7f3b944090754470ecb67ea52987a1559dc92c734273c55bccfe9d';
// const URLPC = 'https://portalciudadano.manta.gob.ec/';
const { WebhookClient } = require("dialogflow-fulfillment");
@ -47,9 +48,15 @@ function conver_capitalice(data) {
}
function AxiosPOST(url, params){
function AxiosPOST(url, params, token = null) {
return new Promise((resolve, reject) => {
axios.post(URLPC+url, params).then(function (response) {
axios.post(URLPC + url, params,
{
headers: {
Authorization: `Bearer ${token}`
}
}
).then(function (response) {
resolve(response.data);
}).catch(function (error) {
resolve({ 'estado': false, 'data': [], 'msg': error });
@ -155,8 +162,7 @@ async function ConsultaClaves(cedula, chang = null){
if (chang != null) {
var _ur = 'consulta_predios_detalle/1/' + cedula + '?boot=true';
}
console.log(_ur);
AxiosPOST(_ur, {}).then(function (result) {
AxiosPOST(_ur, {}, API_TOKEN_PORTAL).then(function (result) {
console.log(result);
if (result['ok']) {
array['ok'] = true;