20 lines
752 B
JavaScript
20 lines
752 B
JavaScript
import { respostaComuns } from "p-respostas";
|
|
import { urlAutenticacao } from "./_urlAutenticacao";
|
|
import node_fetch from "cross-fetch";
|
|
export const codigoContaSite = async ({ ambiente, post, }) => {
|
|
const url = `${urlAutenticacao(ambiente)}/api/codigo_prefeitura_site`;
|
|
try {
|
|
const resp = await 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}`);
|
|
}
|
|
};
|