28 lines
1.1 KiB
JavaScript
28 lines
1.1 KiB
JavaScript
"use strict";
|
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
};
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.listarPrefeituras = exports.tx_listar_prefeituras = void 0;
|
|
const cross_fetch_1 = __importDefault(require("cross-fetch"));
|
|
const p_respostas_1 = require("p-respostas");
|
|
exports.tx_listar_prefeituras = "listar_prefeituras";
|
|
const listarPrefeituras = async ({ url_api_autenticacao, }) => {
|
|
const url = `${url_api_autenticacao}/api/${exports.tx_listar_prefeituras}`;
|
|
return (0, cross_fetch_1.default)(url)
|
|
.then(async (a) => {
|
|
const texto = await a.text();
|
|
try {
|
|
const res = JSON.parse(texto);
|
|
return res;
|
|
}
|
|
catch (error) {
|
|
return p_respostas_1.respostaComuns.erro(`Erro ao listar cidades: ${error.message}`, [
|
|
texto,
|
|
error,
|
|
]);
|
|
}
|
|
})
|
|
.catch((error) => p_respostas_1.respostaComuns.erro(`Erro ao listar cidades: ${error.message}`, [error]));
|
|
};
|
|
exports.listarPrefeituras = listarPrefeituras;
|