29 lines
1.4 KiB
JavaScript
29 lines
1.4 KiB
JavaScript
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
});
|
|
};
|
|
import { respostaComuns } from "p-respostas";
|
|
import { urlAutenticacao } from "./_urlAutenticacao";
|
|
import node_fetch from "cross-fetch";
|
|
export const codigoContaSite = ({ ambiente, post, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
const url = `${urlAutenticacao(ambiente)}/api/codigo_prefeitura_site`;
|
|
try {
|
|
const resp = yield node_fetch(url, {
|
|
method: "POST",
|
|
body: JSON.stringify(post),
|
|
headers: { "Content-Type": "application/json" },
|
|
})
|
|
.then((r) => r.json())
|
|
.catch((e) => respostaComuns.erro("Erro ao enviar registros", [e.message]))
|
|
.then((r) => r);
|
|
return resp;
|
|
}
|
|
catch (e) {
|
|
return respostaComuns.erro(`erro ao buscar código do site: ${e}`);
|
|
}
|
|
});
|